public List <CRM_Customer> GetCustomers() { DataTable dt = DBHelper.GetDataTable("select * from CRM_Customer", null); List <CRM_Customer> rList = new List <CRM_Customer>(); foreach (DataRow row in dt.Rows) { CRM_Customer r = new CRM_Customer() { CompanyID = Convert.ToInt32(row["CompanyID"]), CompanyName = row["CompanyName"].ToString(), CompanyAddress = row["CompanyAddress"].ToString(), CompanyPhone = row["CompanyPhone"].ToString(), OfficialWebsite = row["OfficialWebsite"].ToString(), ContactPerson = row["ContactPerson"].ToString(), CP_Phone = row["CP_Phone"].ToString(), CP_Email = row["CP_Email"].ToString(), CompanyScale = row["CompanyScale"].ToString(), CompanyCategory = row["CompanyCategory"].ToString() }; rList.Add(r); } return(rList); }
public static bool add(crm Crm, string path) { int id = 0; try { var db = dbcrm.CRM_Customer.OrderBy(x => x.id).ToList(); var ob = new CRM_Customer(); ob.id = db.Last().id + 1; id = ob.id; ob.NAME = Crm.Name; ob.MOBIL = Crm.Number; ob.CodeMelli = Crm.NationalCode; ob.SHS_ID = 32906515; ob.cod_Eshterak = ob.id.ToString(); ob.CartKind = "اشتراک"; ob.Mos_id = 0; ob.Lottery = false; //SalMaly=dbcrm.SalMalies.FirstOrDefault(y=>y.SHS_ID==0) dbcrm.CRM_Customer.Add(ob); dbcrm.SaveChanges(); return(true); } catch (Exception error) { dbcrm.CRM_Customer.Remove(dbcrm.CRM_Customer.FirstOrDefault(x => x.id == id)); errors.LogError(error, path); return(false); } }
public List <CRM_Customer> GetCustomer(int id) { DataTable dt = DBHelper.GetDataTable("select * from CRM_Customer where CompanyID=@id", new Dictionary <string, object>() { { "@id", id } }); List <CRM_Customer> rList = new List <CRM_Customer>(); foreach (DataRow row in dt.Rows) { CRM_Customer r = new CRM_Customer() { CompanyID = id, CompanyName = row["CompanyName"].ToString(), CompanyAddress = row["CompanyAddress"].ToString(), CompanyPhone = row["CompanyPhone"].ToString(), OfficialWebsite = row["OfficialWebsite"].ToString(), ContactPerson = row["ContactPerson"].ToString(), CP_Phone = row["CP_Phone"].ToString(), CP_Email = row["CP_Email"].ToString(), CompanyScale = row["CompanyScale"].ToString(), CompanyCategory = row["CompanyCategory"].ToString() }; rList.Add(r); } return(rList); }
protected void InsertBtn_Click(object sender, EventArgs e) { try { ErrorLab.Text = "客戶資料新增成功"; CRM_Customer r = new CRM_Customer() { CompanyID = Convert.ToInt32(CompanyIDTextBox.Text), CompanyName = CompanyNameTextBox.Text, CompanyAddress = CompanyAddressTextBox.Text, CompanyPhone = CompanyPhoneTextBox.Text, OfficialWebsite = OfficialWebsiteTextBox.Text, ContactPerson = ContactPersonTextBox.Text, CP_Phone = CP_PhoneTextBox.Text, CP_Email = CP_EmailTextBox.Text, CompanyScale = CompanyScaleDropDownList.Text, CompanyCategory = CompanyCategoryDropDownList.Text }; CRM_CustomerUtility ru = new CRM_CustomerUtility(); ru.Insert(r); } catch (Exception) { ErrorLab.Text = "客戶資料格式錯誤或已建立,請確認統編"; } }
public void Add(CRM_Customer customer) { if (customer != null) { _dbContext.CRM_Customer.Add(customer); } }
public void InsertCompanyCategorys(CRM_Customer r) { DBHelper.RunTSQL( "insert into CRM_CompanyCategorys values(@category)", new Dictionary <string, object>() { { "@category", r.CompanyCategory } }); }
protected void InsertCompanyCategorysBtn_Click(object sender, EventArgs e) { CRM_Customer r = new CRM_Customer() { CompanyCategory = InsertCompanyCategorysTextBox.Text }; CRM_CustomerUtility ru = new CRM_CustomerUtility(); ru.InsertCompanyCategorys(r); }
/// <summary> /// 修改客户信息 /// </summary> /// <param name="custoemr"></param> /// <returns></returns> public int UpdateCustomer(CRM_Customer custoemr) { ccs.Update(custoemr); int result = ccs.SaveChanges(); if (result > 0) { return(1); } else { return(0); } }
/// <summary> /// 添加一个客户 /// </summary> /// <param name="customer"></param> /// <returns></returns> public int AddCustomer(CRM_Customer customer) { ccs.Add(customer); int result = ccs.SaveChanges(); if (result > 0) { return(1); } else { return(0); } }
private void frmCreateCustomer_Load(object sender, EventArgs e) { //填充输入表单的基本数据 //新建三个表,行业表,客户类型表,公司规模表 //联系人选择使用联系人添加 //通过业务员返回业务员Id if (this.Text == "修改客户信息") { //将得到的信息填充到输入框 frmCustomer fc; fc = (frmCustomer)this.Owner; cc = fc.GetCRM_CustomerModel(); LoadUpdateInfo(); } }
public void Update(CRM_Customer r) { DBHelper.RunTSQL( "update CRM_Customer set CompanyName=@name,CompanyAddress=@addr,CompanyPhone=@cphone,OfficialWebsite=@web,ContactPerson=@cp,CP_Phone=@cpphone,CP_Email=@cpemail,CompanyScale=@scale,CompanyCategory=@category where CompanyID=@id", new Dictionary <string, object>() { { "@id", r.CompanyID }, { "@name", r.CompanyName }, { "@addr", r.CompanyAddress }, { "@cphone", r.CompanyPhone }, { "@web", r.OfficialWebsite }, { "@cp", r.ContactPerson }, { "@cpphone", r.CP_Phone }, { "@cpemail", r.CP_Email }, { "@scale", r.CompanyScale }, { "@category", r.CompanyCategory } }); }
public void Insert(CRM_Customer r) { DBHelper.RunTSQL( "insert into CRM_Customer values(@id,@name,@addr,@cphone,@web,@cp,@cpphone,@cpemail,@scale,@category)", new Dictionary <string, object>() { { "@id", r.CompanyID }, { "@name", r.CompanyName }, { "@addr", r.CompanyAddress }, { "@cphone", r.CompanyPhone }, { "@web", r.OfficialWebsite }, { "@cp", r.ContactPerson }, { "@cpphone", r.CP_Phone }, { "@cpemail", r.CP_Email }, { "@scale", r.CompanyScale }, { "@category", r.CompanyCategory } }); }
public void Update(CRM_Customer customer) { var updatecustomer = _dbContext.CRM_Customer.Find(customer.Id); if (updatecustomer != null) { updatecustomer.MId = customer.MId; updatecustomer.MDate = customer.MDate; updatecustomer.Province = customer.Province; updatecustomer.City = customer.City; updatecustomer.CusName = customer.CusName; updatecustomer.BussinessType = customer.BussinessType; updatecustomer.CusType = customer.CusType; updatecustomer.HomePage = customer.HomePage; updatecustomer.PhoneNum = customer.PhoneNum; updatecustomer.SaleId = customer.SaleId; updatecustomer.IsPublisCus = customer.IsPublisCus; updatecustomer.Scale = customer.Scale; } }
protected void UpdateBtn_Click(object sender, EventArgs e) { CRM_Customer r = new CRM_Customer() { CompanyID = Convert.ToInt32(CompanyID.Text) }; r.CompanyName = CompanyName.Text; r.CompanyAddress = CompanyAddress.Text; r.CompanyPhone = CompanyPhone.Text; r.OfficialWebsite = OfficialWebsite.Text; r.ContactPerson = ContactPerson.Text; r.CP_Phone = CP_Phone.Text; r.CP_Email = CP_Email.Text; r.CompanyScale = CompanyScale.Text; r.CompanyCategory = CompanyCategory.Text; CRM_CustomerUtility ru = new CRM_CustomerUtility(); ru.Update(r); }
protected void UpdateBtn_Click(object sender, EventArgs e) { CRM_Customer r = new CRM_Customer() { CompanyID = Convert.ToInt32(CompanyIDTextBox.Text) }; r.CompanyName = CompanyNameTextBox.Text; r.CompanyAddress = CompanyAddressTextBox.Text; r.CompanyPhone = CompanyPhoneTextBox.Text; r.OfficialWebsite = OfficialWebsiteTextBox.Text; r.ContactPerson = ContactPersonTextBox.Text; r.CP_Phone = CP_PhoneTextBox.Text; r.CP_Email = CP_EmailTextBox.Text; r.CompanyScale = CompanyScaleDropDownList.Text; r.CompanyCategory = CompanyCategoryDropDownList.Text; CRM_CustomerUtility ru = new CRM_CustomerUtility(); ru.Update(r); ErrorLab.Text = "修改客戶資料成功"; }