gy_customerdal.cs
来自「为了便于企业对客户按照地区进行统计查询分析」· CS 代码 · 共 208 行
CS
208 行
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Model;
namespace DataAccess.DAL
{
class Gy_CustomerDAL
{
//Comm.Comm c = new Comm.Comm();
DataAccess.Comm.Comm c = new DataAccess.Comm.Comm();
/// <summary>
/// 查找客户设置
/// </summary>
/// <param name="CusCode"></param>
/// <returns></returns>
public List<Gy_Customer> SelectGy_Customer(string CusCode)
{
SqlConnection sqlcnn = c.conn();
SqlCommand sqlcmd = new SqlCommand();
sqlcmd.CommandText = "SelectGy_Customer";
sqlcmd.CommandType = CommandType.StoredProcedure;
sqlcmd.Parameters.AddWithValue("@CusCode", CusCode);
sqlcmd.Connection = sqlcnn;
SqlDataReader reader = null;
List<Gy_Customer> list = new List<Gy_Customer>();
try {
sqlcnn.Open();
reader = sqlcmd.ExecuteReader();
while (reader.Read())
{
Gy_Customer gy_customer = new Gy_Customer();
gy_customer.CusCode=reader["CusCode"].ToString();
gy_customer.CusName = reader["CusName"].ToString();
gy_customer.StopFlag =Convert.ToBoolean( reader["StopFlag"].ToString());
gy_customer.AreaCode = reader["AreaCode"].ToString();
gy_customer.TradeCode = reader["TradeCode"].ToString();
gy_customer.Address = reader["Address"].ToString();
gy_customer.PostCode = reader["PostCode"].ToString();
gy_customer.Bank = reader["Bank"].ToString();
gy_customer.BankAccount = reader["BankAccount"].ToString();
gy_customer.RelationDate =Convert.ToDateTime( reader["RelationDate"].ToString());
gy_customer.EMail = reader["EMail"].ToString();
gy_customer.WorkNet = reader["WorkNet"].ToString();
gy_customer.ContactPerson = reader["ContactPerson"].ToString();
gy_customer.ContactType = reader["ContactType"].ToString();
gy_customer.PersonCode = reader["PersonCode"].ToString();
gy_customer.DesAddress = reader["DesAddress"].ToString();
gy_customer.DeptCode = reader["DeptCode"].ToString();
list.Add(gy_customer);
}
}
catch (SqlException e)
{
throw e;
}
finally
{
if (sqlcnn.State != ConnectionState.Closed)
{
sqlcnn.Close();
}
}
return list;
}
/// <summary>
/// 添加客户信息
/// </summary>
/// <param name="CusCode"></param>
/// <param name="CusName"></param>
/// <param name="StopFlag"></param>
/// <param name="AreaCode"></param>
/// <param name="TradeCode"></param>
/// <param name="Address"></param>
/// <param name="PostCode"></param>
/// <param name="Bank"></param>
/// <param name="BankAccount"></param>
/// <param name="RelationDate"></param>
/// <param name="EMail"></param>
/// <param name="WorkNet"></param>
/// <param name="ContactPerson"></param>
/// <param name="ContactType"></param>
/// <param name="PersonCode"></param>
/// <param name="DesAddress"></param>
/// <param name="DeptCode"></param>
public void InsertGy_Customer(Gy_Customer insert_gy_custom)
{
SqlParameter [] parameters=
{
new SqlParameter("@CusCode", SqlDbType.VarChar,20),
new SqlParameter("@CusName", SqlDbType.VarChar,50),
new SqlParameter("@StopFlag", SqlDbType.Bit,1),
new SqlParameter("@AreaCode", SqlDbType.VarChar,20),
new SqlParameter("@TradeCode", SqlDbType.VarChar,20),
new SqlParameter("@Address", SqlDbType.VarChar,50),
new SqlParameter("@PostCode", SqlDbType.VarChar,20),
new SqlParameter("@Bank", SqlDbType.VarChar,50),
new SqlParameter("@BankAccount", SqlDbType.VarChar,50),
new SqlParameter("@RelationDate", SqlDbType.DateTime),
new SqlParameter("@EMail", SqlDbType.VarChar,60),
new SqlParameter("@WorkNet", SqlDbType.VarChar,50),
new SqlParameter("@ContactPerson", SqlDbType.VarChar,50),
new SqlParameter("@ContactType", SqlDbType.VarChar,50),
new SqlParameter("@PersonCode", SqlDbType.VarChar,20),
new SqlParameter("@DesAddress", SqlDbType.VarChar,50),
new SqlParameter("@DeptCode", SqlDbType.VarChar,20)};
parameters[0].Value = insert_gy_custom.CusCode;
parameters[1].Value = insert_gy_custom.CusName;
parameters[2].Value = insert_gy_custom.StopFlag;
parameters[3].Value = insert_gy_custom.AreaCode;
parameters[4].Value = insert_gy_custom.TradeCode;
parameters[5].Value = insert_gy_custom.Address;
parameters[6].Value = insert_gy_custom.PostCode;
parameters[7].Value = insert_gy_custom.Bank;
parameters[8].Value = insert_gy_custom.BankAccount;
parameters[9].Value = insert_gy_custom.RelationDate;
parameters[10].Value = insert_gy_custom.EMail;
parameters[11].Value = insert_gy_custom.WorkNet;
parameters[12].Value = insert_gy_custom.ContactPerson;
parameters[13].Value = insert_gy_custom.ContactType;
parameters[14].Value = insert_gy_custom.PersonCode;
parameters[15].Value = insert_gy_custom.DesAddress;
parameters[16].Value = insert_gy_custom.DeptCode;
c.Excute("InsertCustomer",parameters);
}
/// <summary>
/// 更新客户信息
/// </summary>
/// <param name="CusCode"></param>
/// <param name="CusName"></param>
/// <param name="StopFlag"></param>
/// <param name="AreaCode"></param>
/// <param name="TradeCode"></param>
/// <param name="Address"></param>
/// <param name="PostCode"></param>
/// <param name="Bank"></param>
/// <param name="BankAccount"></param>
/// <param name="RelationDate"></param>
/// <param name="EMail"></param>
/// <param name="WorkNet"></param>
/// <param name="ContactPerson"></param>
/// <param name="ContactType"></param>
/// <param name="PersonCode"></param>
/// <param name="DesAddress"></param>
/// <param name="DeptCode"></param>
public void UpdateGy_Customer(Gy_Customer update_gy_customer)
{
SqlParameter[] parameters = {
new SqlParameter("@CusCode", SqlDbType.VarChar,20),
new SqlParameter("@CusName", SqlDbType.VarChar,50),
new SqlParameter("@StopFlag", SqlDbType.Bit,1),
new SqlParameter("@AreaCode", SqlDbType.VarChar,20),
new SqlParameter("@TradeCode", SqlDbType.VarChar,20),
new SqlParameter("@Address", SqlDbType.VarChar,50),
new SqlParameter("@PostCode", SqlDbType.VarChar,20),
new SqlParameter("@Bank", SqlDbType.VarChar,50),
new SqlParameter("@BankAccount", SqlDbType.VarChar,50),
new SqlParameter("@RelationDate", SqlDbType.DateTime),
new SqlParameter("@EMail", SqlDbType.VarChar,60),
new SqlParameter("@WorkNet", SqlDbType.VarChar,50),
new SqlParameter("@ContactPerson", SqlDbType.VarChar,50),
new SqlParameter("@ContactType", SqlDbType.VarChar,50),
new SqlParameter("@PersonCode", SqlDbType.VarChar,20),
new SqlParameter("@DesAddress", SqlDbType.VarChar,50),
new SqlParameter("@DeptCode", SqlDbType.VarChar,20)};
parameters[0].Value = update_gy_customer.CusCode;
parameters[1].Value = update_gy_customer.CusName;
parameters[2].Value = update_gy_customer.StopFlag;
parameters[3].Value = update_gy_customer.AreaCode;
parameters[4].Value = update_gy_customer.TradeCode;
parameters[5].Value = update_gy_customer.Address;
parameters[6].Value = update_gy_customer.PostCode;
parameters[7].Value = update_gy_customer.Bank;
parameters[8].Value = update_gy_customer.BankAccount;
parameters[9].Value = update_gy_customer.RelationDate;
parameters[10].Value = update_gy_customer.EMail;
parameters[11].Value = update_gy_customer.WorkNet;
parameters[12].Value = update_gy_customer.ContactPerson;
parameters[13].Value = update_gy_customer.ContactType;
parameters[14].Value = update_gy_customer.PersonCode;
parameters[15].Value = update_gy_customer.DesAddress;
parameters[16].Value = update_gy_customer.DeptCode;
c.Excute("UpdateGy_Customer",parameters);
}
/// <summary>
/// 删除客户信息
/// </summary>
/// <param name="CusCode"></param>
public void DeleteGy_Customer(Gy_Customer delete_gy_customer)
{
SqlParameter [] parmeters=
{
new SqlParameter("@CusCode",SqlDbType.VarChar,20)};
parmeters[0].Value=delete_gy_customer.CusCode;
c.Excute("DeleteGy_Customer", parmeters);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?