protected void btnCusDetailUpDown_Click(object sender, EventArgs e) { CRM_CUST c_cust = new CRM_CUST(); c_cust.Cus_ID = Convert.ToInt32(txt_cus_id.Value); c_cust.Email = page_Email.Value; c_cust.Phone = page_Phone.Value; c_cust._Cus_Name = page_Cus_Name.Value; BLLTable <CRM_CUST> .Factory(conn).Update(c_cust, CRM_CUST.Attribute.Cus_ID); CRM_CUSTOMER c_customer = new CRM_CUSTOMER(); c_customer.Cus_Id = Convert.ToInt32(txt_cus_id.Value); c_customer.CompanyAddress = page_CompanyAddress.Value; c_customer.CompanyName = page_CompanyName.Value; c_customer.ShopName = page_ShopName.Value; c_customer.ShopNameURL = page_ShopNameURL.Value; c_customer.WangWangId = page_WangWangId.Value; c_customer.CustQQ = page_CustQQ.Value; BLLTable <CRM_CUSTOMER> .Factory(conn).Update(c_customer, CRM_CUSTOMER.Attribute.Cus_Id); lit_CompanyAddress.Text = page_CompanyAddress.Value; lit_CompanyName.Text = page_CompanyName.Value; lit_ShopName.Text = page_ShopName.Value; lit_ShopNameURL.Text = page_ShopNameURL.Value; lit_WangWangId.Text = page_WangWangId.Value; lit_CustQQ.Text = page_CustQQ.Value; lit_Phone.Text = page_Phone.Value; lit_Email.Text = page_Email.Value; lit_Cus_Name.Text = page_Cus_Name.Value; }
protected void Page_Load(object sender, EventArgs e) { //在列表里点击删除按钮,通过AJAX执行这里的后台代码,删除一条记录 if (Request["DelCus_Id"] != null) { int re = BLLTable <CRM_CUSTOMER> .Factory(conn).Delete(CRM_CUSTOMER.Attribute.Cus_Id, Request["DelCus_Id"]); if (re > 0) { Response.Write("1");//可以输出数字 大于0 表示操作成功,也可以直接输出 字符串,客户端将弹出此字符串信息作为提示 } else { Response.Write("删除失败!"); } } //在列表顶部点击删除按钮,通过AJAX执行这里的后台代码,删除多条记录 if (Request["DelKeyIDS"] != null) { CRM_CUSTOMER cond = new CRM_CUSTOMER(); cond.In(CRM_CUSTOMER.Attribute.Cus_Id, Request["DelKeyIDS"]); int re = BLLTable <CRM_CUSTOMER> .Factory(conn).Delete(cond); if (re > 0) { Response.Write("1");//可以输出数字 大于0 表示操作成功,也可以直接输出 字符串,客户端将弹出此字符串信息作为提示 } else { Response.Write("删除失败!"); } } //在用户详细信息查看编辑页面,点保存时,通过AJAX执行这里的后台代码,实现部门字段的更新 if (Request["saveInfo"] != null) { CRM_CUSTOMER val = new CRM_CUSTOMER(); val.Cus_Id = int.Parse(Request["FieldKeyID"]); List <AttributeItem> lstCol = val.af_AttributeItemList; for (int i = 0; i < lstCol.Count; i++) { if (!string.IsNullOrEmpty(Request["txt" + lstCol[i].FieldName])) { val.SetValue(lstCol[i].FieldName, Request["txt" + lstCol[i].FieldName]); } } BLLTable <CRM_CUSTOMER> .Factory(conn).Update(val, CRM_CUSTOMER.Attribute.Cus_Id); Response.Write("修改用户信息成功"); } Response.End(); }
protected void Page_Load(object sender, EventArgs e) { #region//默认隐藏的列 //hideTableColumnList = new List<AttributeItem>(); //hideTableColumnList.Add(CRM_CUSTOMER.Attribute.EXP1); //hideTableColumnList.Add(CRM_CUSTOMER.Attribute.EXP2); //hideTableColumnList.Add(CRM_CUSTOMER.Attribute.EXP3); //valObj.LoadAllAttributes(true);//暂时加此代码,以后框架更新将不需要 //valObj.Remove(hideTableColumnList); //hideFindColumnList = new List<AttributeItem>(); //hideFindColumnList.Add(CRM_CUSTOMER.Attribute.EXP1); //hideFindColumnList.Add(CRM_CUSTOMER.Attribute.EXP2); //hideFindColumnList.Add(CRM_CUSTOMER.Attribute.EXP3); #endregion valObj.OrderBy(CRM_CUSTOMER.Attribute.Cus_Id, Order.Desc); if (!IsPostBack) { btnFind.Text = LanguageService.GetLanguageString("btnFind", "查询"); aspPager.PageSize = 10; aspPager.CurrentPageIndex = 1; if (!string.IsNullOrEmpty(Request["ids"])) { CRM_CUSTOMER roleOld = new CRM_CUSTOMER(); roleOld.Where(CRM_CUSTOMER.Attribute.Cus_Id, Request["ids"].ToString()); listObj = BLLTable <CRM_CUSTOMER> .Factory(conn).Select(valObj, roleOld); for (int i = 0; i < listObj.Count; i++) { if (i > 0) { hidOld.Value += ","; hidInitIDS.Value += ","; } hidOld.Value += "{ID:'" + listObj[i].Cus_Id + "',Name:'" + listObj[i].Cus_Id + "'}";//这里的Name用于显示在列表中,请自行重定义。 hidInitIDS.Value += listObj[i].Cus_Id; } } try { listObj = BLLTable <CRM_CUSTOMER> .Factory(conn).SelectByPage(valObj, condObj, aspPager.PageSize, 1, ref recount); repList.DataSource = listObj; repList.DataBind(); aspPager.RecordCount = recount; } catch (Exception ex) { litWarn.Text = ex.Message; } } }
/// <summary> /// 将过期客户投入公海 /// </summary> public void OutPutCustToHighSeas() { int count = 0; CRM_STAFF_CUSTOMER_CONTACTRECORDS cSelVal = new CRM_STAFF_CUSTOMER_CONTACTRECORDS(); cSelVal._SID = ""; cSelVal._Cus_ID = 0; CRM_STAFF_CUSTOMER_CONTACTRECORDS ccon = new CRM_STAFF_CUSTOMER_CONTACTRECORDS(); ccon.Where("{0} is null and {1} < '{2}'", CRM_STAFF_CUSTOMER_CONTACTRECORDS.Attribute.ContactTime, CRM_STAFF_CUSTOMER_CONTACTRECORDS.Attribute.NextContactTime.FieldName, DateTime.Now.Date.AddDays(-60)); List <CRM_STAFF_CUSTOMER_CONTACTRECORDS> csccList = BLLTable <CRM_STAFF_CUSTOMER_CONTACTRECORDS> .Factory(conn).Select(cSelVal, ccon); if (csccList.Count < 1) { return; } CRM_STAFF_CUSTOMER_CONTACTRECORDS cval = new CRM_STAFF_CUSTOMER_CONTACTRECORDS(); cval._ContactTime = DateTime.Now; cval._ContactRecords = "过期联系人,系统自动丢入公海!"; count += BLLTable <CRM_STAFF_CUSTOMER_CONTACTRECORDS> .Factory(conn).Update(cval, ccon);//更新未联系为已联系 List <string> sidList = new List <string>(); List <int> cusidList = new List <int>(); foreach (CRM_STAFF_CUSTOMER_CONTACTRECORDS cscc in csccList) { if (!sidList.Contains(cscc.SID)) { sidList.Add(cscc.SID); } if (!cusidList.Contains(cscc.Cus_ID)) { cusidList.Add(cscc.Cus_ID); } } string[] sidArr = sidList.ToArray(); int[] cusidArr = cusidList.ToArray(); CRM_STAFF_CUSTOMER con = new CRM_STAFF_CUSTOMER();//删除员工与客户关联 con.In(CRM_STAFF_CUSTOMER.Attribute.SID, sidArr); con.In(CRM_STAFF_CUSTOMER.Attribute.Cus_ID, cusidArr); count += BLLTable <CRM_STAFF_CUSTOMER> .Factory(conn).Delete(con); CRM_CUSTOMER ccCon = new CRM_CUSTOMER(); ccCon.In(CRM_CUSTOMER.Attribute.Cus_Id, cusidArr); CRM_CUSTOMER ccVal = new CRM_CUSTOMER(); ccVal._LoadHighSeasTime = DateTime.Now; count += BLLTable <CRM_CUSTOMER> .Factory(conn).Update(ccVal, ccCon);//更新加入公海时间 }
protected void Page_Load(object sender, EventArgs e) { //���б�����ɾ����ť��ͨ��AJAXִ������ĺ�̨���룬ɾ��һ����¼ if (Request["DelCus_Id"] != null) { int re = BLLTable<CRM_CUSTOMER>.Factory(conn).Delete(CRM_CUSTOMER.Attribute.Cus_Id, Request["DelCus_Id"]); if (re > 0) { Response.Write("1");//����������� ����0 ��ʾ�����ɹ���Ҳ����ֱ����� �ַ������ͻ��˽��������ַ�����Ϣ��Ϊ��ʾ } else { Response.Write("ɾ��ʧ�ܣ�"); } } //���б�������ɾ����ť��ͨ��AJAXִ������ĺ�̨���룬ɾ��������¼ if (Request["DelKeyIDS"] != null) { CRM_CUSTOMER cond = new CRM_CUSTOMER(); cond.In(CRM_CUSTOMER.Attribute.Cus_Id, Request["DelKeyIDS"]); int re = BLLTable<CRM_CUSTOMER>.Factory(conn).Delete(cond); if (re > 0) { Response.Write("1");//����������� ����0 ��ʾ�����ɹ���Ҳ����ֱ����� �ַ������ͻ��˽��������ַ�����Ϣ��Ϊ��ʾ } else { Response.Write("ɾ��ʧ�ܣ�"); } } //���û���ϸ��Ϣ�鿴�༭ҳ�棬�㱣��ʱ��ͨ��AJAXִ������ĺ�̨���룬ʵ�ֲ����ֶεĸ��� if (Request["saveInfo"] != null) { CRM_CUSTOMER val = new CRM_CUSTOMER(); val.Cus_Id = int.Parse(Request["FieldKeyID"]); List<AttributeItem> lstCol = val.af_AttributeItemList; for (int i = 0; i < lstCol.Count; i++) { if (!string.IsNullOrEmpty(Request["txt" + lstCol[i].FieldName])) { val.SetValue(lstCol[i].FieldName,Request["txt" + lstCol[i].FieldName]); } } BLLTable<CRM_CUSTOMER>.Factory(conn).Update(val, CRM_CUSTOMER.Attribute.Cus_Id); Response.Write("���û���Ϣ�ɹ�"); } Response.End(); }
protected void btnFind_Click(object sender, EventArgs e) { condObj = new CRM_CUSTOMER(); if(txtCompanyName.Value !="" ) condObj.Like_OR(CRM_CUSTOMER.Attribute.CompanyName, Convert.ToString(txtCompanyName.Value)); if(txtCompanyAddress.Value !="" ) condObj.Like_OR(CRM_CUSTOMER.Attribute.CompanyAddress, Convert.ToString(txtCompanyAddress.Value)); if(txtShopName.Value !="" ) condObj.Like_OR(CRM_CUSTOMER.Attribute.ShopName, Convert.ToString(txtShopName.Value)); if(txtShopNameURL.Value !="" ) condObj.Like_OR(CRM_CUSTOMER.Attribute.ShopNameURL, Convert.ToString(txtShopNameURL.Value)); if(txtCustSex.Value !="" ) condObj.Like_OR(CRM_CUSTOMER.Attribute.CustSex, Convert.ToInt32(txtCustSex.Value)); if(txtBirthday.Value !="" ) condObj.Like_OR(CRM_CUSTOMER.Attribute.Birthday, Convert.ToDateTime(txtBirthday.Value)); if(txtWangWangId.Value !="" ) condObj.Like_OR(CRM_CUSTOMER.Attribute.WangWangId, Convert.ToString(txtWangWangId.Value)); if(txtCustQQ.Value !="" ) condObj.Like_OR(CRM_CUSTOMER.Attribute.CustQQ, Convert.ToString(txtCustQQ.Value)); if(txtLastEditors.Value !="" ) condObj.Like_OR(CRM_CUSTOMER.Attribute.LastEditors, Convert.ToString(txtLastEditors.Value)); if(txtLoadHighSeasTime.Value !="" ) condObj.Like_OR(CRM_CUSTOMER.Attribute.LoadHighSeasTime, Convert.ToDateTime(txtLoadHighSeasTime.Value)); if(txtCus_Id.Value !="" ) condObj.Like_OR(CRM_CUSTOMER.Attribute.Cus_Id, Convert.ToInt32(txtCus_Id.Value)); try { hidCondition.Value = condObj.ToJson(20); listObj = BLLTable<CRM_CUSTOMER>.Factory(conn).SelectByPage(valObj, condObj, aspPager.PageSize, 1, ref recount); repList.DataSource = listObj; repList.DataBind(); } catch (Exception ex) { litWarn.Text = ex.Message; } }
protected void aspPager_PageChanged(object sender, EventArgs e) { try { if (hidCondition.Value != "") { condObj = JsonServiceBase.FromJson<CRM_CUSTOMER>(hidCondition.Value); } listObj = BLLTable<CRM_CUSTOMER>.Factory(conn).SelectByPage(valObj, condObj, aspPager.PageSize, aspPager.CurrentPageIndex, ref recount); repCus.DataSource = listObj; repCus.DataBind(); } catch (Exception ex) { litWarn.Text = ex.Message; } }
protected void aspPager_PageChanged(object sender, EventArgs e) { try { if (hidCondition.Value != "") { condObj = JsonServiceBase.FromJson <CRM_CUSTOMER>(hidCondition.Value); } listObj = BLLTable <CRM_CUSTOMER> .Factory(conn).SelectByPage(valObj, condObj, aspPager.PageSize, aspPager.CurrentPageIndex, ref recount); repCus.DataSource = listObj; repCus.DataBind(); } catch (Exception ex) { litWarn.Text = ex.Message; } }
protected void btnClientToHighSeas_Click(object sender, EventArgs e) { CRM_STAFF_CUSTOMER con = new CRM_STAFF_CUSTOMER(); con._Cus_ID = Convert.ToInt32(txt_cus_id.Value); con._SID = txt_s_id.Value; int count = BLLTable <CRM_STAFF_CUSTOMER> .Factory(conn).Delete(con); CRM_STAFF_CUSTOMER_CONTACTRECORDS cval = new CRM_STAFF_CUSTOMER_CONTACTRECORDS(); cval.ID = Convert.ToDecimal(txt_ContactDetailID.Value); cval.ContactTime = DateTime.Now; cval.ContactRecords = "被" + userBase.RealName + "(" + userBase.UserID + ")抛入公海"; count += BLLTable <CRM_STAFF_CUSTOMER_CONTACTRECORDS> .Factory(conn).Update(cval, CRM_STAFF_CUSTOMER_CONTACTRECORDS.Attribute.ID); CRM_CUSTOMER ccVal = new CRM_CUSTOMER(); ccVal._Cus_Id = con._Cus_ID; ccVal._LoadHighSeasTime = DateTime.Now; count += BLLTable <CRM_CUSTOMER> .Factory(conn).Update(ccVal, CRM_CUSTOMER.Attribute.Cus_Id);//更新加入公海时间 if (count > 2) { //丢入公海成功 AgileFrame.Core.ScriptHelper.Alert(Page, "投入公海成功!"); AgileFrame.Core.ScriptHelper.CloseMe(Page); } else { //丢入公海失败 AgileFrame.Core.ScriptHelper.Alert(Page, "投入公海失败!"); return; } addCustConnDailt.Visible = false; Cus_Status.Enabled = false; Cus_Status.SelectedIndex = Convert.ToInt32(txt_cus_status.Value); btnClientToHighSeas.Visible = false; //UpdatePanel3.UpdateMode = UpdatePanelUpdateMode.Always; //UpdatePanel3.Update(); }
/// <summary> /// 将过期客户投入公海 /// </summary> public void OutPutCustToHighSeas() { int count = 0; CRM_STAFF_CUSTOMER_CONTACTRECORDS cSelVal = new CRM_STAFF_CUSTOMER_CONTACTRECORDS(); cSelVal._SID = ""; cSelVal._Cus_ID = 0; CRM_STAFF_CUSTOMER_CONTACTRECORDS ccon = new CRM_STAFF_CUSTOMER_CONTACTRECORDS(); ccon.Where("{0} is null and {1} < '{2}'",CRM_STAFF_CUSTOMER_CONTACTRECORDS.Attribute.ContactTime, CRM_STAFF_CUSTOMER_CONTACTRECORDS.Attribute.NextContactTime.FieldName, DateTime.Now.Date.AddDays(-60)); List<CRM_STAFF_CUSTOMER_CONTACTRECORDS> csccList = BLLTable<CRM_STAFF_CUSTOMER_CONTACTRECORDS>.Factory(conn).Select(cSelVal, ccon); if (csccList.Count < 1) return; CRM_STAFF_CUSTOMER_CONTACTRECORDS cval = new CRM_STAFF_CUSTOMER_CONTACTRECORDS(); cval._ContactTime = DateTime.Now; cval._ContactRecords = "过期联系人,系统自动丢入公海!"; count += BLLTable<CRM_STAFF_CUSTOMER_CONTACTRECORDS>.Factory(conn).Update(cval, ccon);//更新未联系为已联系 List<string> sidList = new List<string>(); List<int> cusidList = new List<int>(); foreach (CRM_STAFF_CUSTOMER_CONTACTRECORDS cscc in csccList) { if (!sidList.Contains(cscc.SID)) sidList.Add(cscc.SID); if (!cusidList.Contains(cscc.Cus_ID)) cusidList.Add(cscc.Cus_ID); } string[] sidArr = sidList.ToArray(); int[] cusidArr = cusidList.ToArray(); CRM_STAFF_CUSTOMER con = new CRM_STAFF_CUSTOMER();//删除员工与客户关联 con.In(CRM_STAFF_CUSTOMER.Attribute.SID, sidArr); con.In(CRM_STAFF_CUSTOMER.Attribute.Cus_ID, cusidArr); count += BLLTable<CRM_STAFF_CUSTOMER>.Factory(conn).Delete(con); CRM_CUSTOMER ccCon = new CRM_CUSTOMER(); ccCon.In(CRM_CUSTOMER.Attribute.Cus_Id, cusidArr); CRM_CUSTOMER ccVal = new CRM_CUSTOMER(); ccVal._LoadHighSeasTime = DateTime.Now; count += BLLTable<CRM_CUSTOMER>.Factory(conn).Update(ccVal, ccCon);//更新加入公海时间 }
protected bool CheckTheSame() { if (string.IsNullOrEmpty(txt_addMobPhone.Value) && string.IsNullOrEmpty(txt_addPhone.Value) && string.IsNullOrEmpty(txt_addQQ.Value) && string.IsNullOrEmpty(txt_addEmail.Value)) { lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">联系方式至少要填一项!</a>"; lit_AddInfo.Visible = true; return(true); } CRM_CUSTOMER cctomer = new CRM_CUSTOMER(); CRM_CUST cct = new CRM_CUST(); string cctomerLike = " 1<>1 "; string cctLike = " 1<>1 "; if (!string.IsNullOrEmpty(txt_addWangWangId.Value)) { cctomerLike += " or " + CRM_CUSTOMER.Attribute.WangWangId.FieldName + " like '" + txt_addWangWangId.Value.Trim().Replace(" ", "") + "'"; } if (!string.IsNullOrEmpty(txt_addShopUrl.Value)) { txt_addShopUrl.Value = txt_addShopUrl.Value.Trim().Replace(" ", "").ToLower(); if (!txt_addShopUrl.Value.Contains(".com")) { lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">网店地址错误!</a>"; lit_AddInfo.Visible = true; return(true); } int end = txt_addShopUrl.Value.IndexOf(".com") + 4; if (txt_addShopUrl.Value.Contains("://")) { int start = txt_addShopUrl.Value.IndexOf("://"); if (end - start <= 0) { lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">网店地址错误!</a>"; lit_AddInfo.Visible = true; return(true); } string url = txt_addShopUrl.Value.Substring(start, end - start); cctomerLike += " or " + CRM_CUSTOMER.Attribute.ShopNameURL.FieldName + " like '%" + url + "%'"; //cctomerLike += CRM_CUSTOMER.Attribute.ShopNameURL.FieldName + " like 'http://" + txt_addShopUrl.Value.Trim().Replace(" ", "") + "%' or "; } else { string url = txt_addShopUrl.Value.Substring(0, end); cctomerLike += " or " + CRM_CUSTOMER.Attribute.ShopNameURL.FieldName + " like '" + url + "%'"; //cctomerLike += CRM_CUSTOMER.Attribute.ShopNameURL.FieldName + " like 'http://" + txt_addShopUrl.Value.Trim().Replace(" ", "") + "%' or "; } } if (!string.IsNullOrEmpty(txt_addComName.Value)) { cctomerLike += " or " + CRM_CUSTOMER.Attribute.CompanyName.FieldName + " like '" + txt_addComName.Value.Trim().Replace(" ", "") + "'"; } cctomer.Where(cctomerLike); if (!string.IsNullOrEmpty(txt_addQQ.Value)) { cctLike += " or " + CRM_CUST.Attribute.QQ.FieldName + " like '" + txt_addQQ.Value.Trim().Replace(" ", "") + "'"; } if (!string.IsNullOrEmpty(txt_addPhone.Value)) { cctLike += " or " + CRM_CUST.Attribute.Phone.FieldName + " like '" + txt_addPhone.Value.Trim().Replace(" ", "") + "'"; } if (!string.IsNullOrEmpty(txt_addMobPhone.Value)) { cctLike += " or " + CRM_CUST.Attribute.MobPhone.FieldName + " like '" + txt_addMobPhone.Value.Trim().Replace(" ", "") + "'"; } if (!string.IsNullOrEmpty(txt_addEmail.Value)) { cctLike += " or " + CRM_CUST.Attribute.Email.FieldName + " like '" + txt_addEmail.Value.Trim().Replace(" ", "") + "'"; } cct.Where(cctLike); if (BLLTable <CRM_CUSTOMER> .Exists(cctomer) || BLLTable <CRM_CUST> .Exists(cct)) { lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">添加失败!系统中存在该用户!</a>"; lit_AddInfo.Visible = true; return(true); } return(false); }
protected void btnOK_Click(object sender, EventArgs e) { try { CRM_CUSTOMER valObj = new CRM_CUSTOMER(); if (txtCompanyName.Value != "") { valObj.CompanyName = Convert.ToString(txtCompanyName.Value); } if (txtCompanyAddress.Value != "") { valObj.CompanyAddress = Convert.ToString(txtCompanyAddress.Value); } if (txtShopName.Value != "") { valObj.ShopName = Convert.ToString(txtShopName.Value); } if (txtShopNameURL.Value != "") { valObj.ShopNameURL = Convert.ToString(txtShopNameURL.Value); } if (txtCustSex.Value != "") { valObj.CustSex = Convert.ToInt32(txtCustSex.Value); } if (txtBirthday.Value != "") { valObj.Birthday = Convert.ToDateTime(txtBirthday.Value); } if (txtWangWangId.Value != "") { valObj.WangWangId = Convert.ToString(txtWangWangId.Value); } if (txtCustQQ.Value != "") { valObj.CustQQ = Convert.ToString(txtCustQQ.Value); } if (txtLastEditors.Value != "") { valObj.LastEditors = Convert.ToString(txtLastEditors.Value); } if (txtLoadHighSeasTime.Value != "") { valObj.LoadHighSeasTime = Convert.ToDateTime(txtLoadHighSeasTime.Value); } if (txtCus_Id.Value != "") { valObj.Cus_Id = Convert.ToInt32(txtCus_Id.Value); } if (keyid != "") { valObj.Cus_Id = Convert.ToInt32(keyid); count = BLLTable <CRM_CUSTOMER> .Factory(conn).Update(valObj, CRM_CUSTOMER.Attribute.Cus_Id); } else { count = BLLTable <CRM_CUSTOMER> .Factory(conn).Insert(valObj, CRM_CUSTOMER.Attribute.Cus_Id); keyid = valObj.Cus_Id.ToString(); } if (count > 0) { StringBuilder sbData = new StringBuilder("({valObj:''"); List <AttributeItem> lstCol = valObj.af_AttributeItemList; for (int i = 0; i < lstCol.Count; i++) { object val = valObj.GetValue(lstCol[i]); if (val != null) { sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'"); } } sbData.Append("})"); Button btn = (Button)sender; if (btn.ID == "btnOK") { if (ViewState["hadSave"] == null) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = '" + sbData.ToString() + "';}else{window.returnValue = '" + sbData.ToString() + "';}window.close();", true); } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true); } } else { txtCompanyName.Value = ""; txtCompanyAddress.Value = ""; txtShopName.Value = ""; txtShopNameURL.Value = ""; txtCustSex.Value = ""; txtBirthday.Value = ""; txtWangWangId.Value = ""; txtCustQQ.Value = ""; txtLastEditors.Value = ""; txtLoadHighSeasTime.Value = ""; txtCus_Id.Value = ""; } } } catch (Exception ex) { litWarn.Text = ex.Message; } }
protected void btnSub_Click(object sender, EventArgs e) { lit_AddInfo.Text = ""; lit_AddInfo.Visible = false; CRM_STAFF_CUSTOMER cscVal = new CRM_STAFF_CUSTOMER(); cscVal._Cus_ID = 0; CRM_STAFF_CUSTOMER cscCon = new CRM_STAFF_CUSTOMER(); cscCon._SID = hid_SID.Value; List <CRM_STAFF_CUSTOMER> cscList = BLLTable <CRM_STAFF_CUSTOMER> .Factory(conn).Select(cscVal, cscCon); if (cscList.Count >= 500) { lit_AddInfo.Visible = true; lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">添加失败!客户数达到上限500个。</a>"; return; } if (CheckTheSame()) { return; } CRM_CUSTOMER c_customer = new CRM_CUSTOMER(); if (!string.IsNullOrEmpty(txt_addComAddress.Value)) { c_customer.CompanyAddress = txt_addComAddress.Value.Trim().Replace(" ", ""); } c_customer._CustSex = txt_addCustSexMan.Checked ? 1 : 0; if (!string.IsNullOrEmpty(txt_addShopName.Value)) { c_customer._ShopName = txt_addShopName.Value.Trim().Replace(" ", ""); } if (!string.IsNullOrEmpty(txt_addShopUrl.Value)) { c_customer._ShopNameURL = txt_addShopUrl.Value.Trim().Replace(" ", ""); } if (!string.IsNullOrEmpty(txt_addWangWangId.Value)) { c_customer._WangWangId = txt_addWangWangId.Value.Trim().Replace(" ", ""); } if (!string.IsNullOrEmpty(txt_addComName.Value)) { c_customer._CompanyName = txt_addComName.Value.Trim().Replace(" ", ""); } else { c_customer._CompanyName = txt_addShopName.Value.Trim().Replace(" ", ""); } c_customer._LastEditors = hid_SID.Value; int count = BLLTable <CRM_CUSTOMER> .Factory(conn).Insert(c_customer); if (count < 1)//插入不成功 { lit_AddInfo.Visible = true; lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">添加失败!</a>"; return; } c_customer.OrderBy(CRM_CUSTOMER.Attribute.Cus_Id, Order.Desc); c_customer.Top(1); CRM_CUSTOMER c_customerval = new CRM_CUSTOMER(); c_customerval.Cus_Id = 0; List <CRM_CUSTOMER> c_customercusid = BLLTable <CRM_CUSTOMER> .Factory(conn).Select(c_customerval, c_customer); if (c_customercusid.Count < 1)//插入不成功? { lit_AddInfo.Visible = true; lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">添加失败!</a>"; return; } CRM_CUST c_cust = new CRM_CUST(); c_cust._Cus_ID = c_customercusid[0].Cus_Id; if (!string.IsNullOrEmpty(txt_addCustName.Value)) { c_cust._Cus_Name = txt_addCustName.Value.Trim().Replace(" ", ""); } if (!string.IsNullOrEmpty(txt_addEmail.Value)) { c_cust._Email = txt_addEmail.Value.Trim().Replace(" ", ""); } if (!string.IsNullOrEmpty(txt_addMobPhone.Value)) { c_cust._MobPhone = txt_addMobPhone.Value.Trim().Replace(" ", ""); } if (!string.IsNullOrEmpty(txt_addPhone.Value)) { c_cust._Phone = txt_addPhone.Value.Trim().Replace(" ", ""); } if (!string.IsNullOrEmpty(txt_addQQ.Value)) { c_cust._QQ = txt_addQQ.Value.Trim().Replace(" ", ""); } if (!string.IsNullOrEmpty(txt_addCustName.Value)) { c_cust._ContactName = txt_addCustName.Value.Trim().Replace(" ", ""); } c_cust._AddTime = DateTime.Now; c_cust._EditTime = DateTime.Now; count += BLLTable <CRM_CUST> .Factory(conn).Insert(c_cust); if (count < 2)//插入不成功 { lit_AddInfo.Visible = true; lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">添加失败!</a>"; return; } if (string.IsNullOrEmpty(hid_SID.Value)) { return; } DateTime lastConTime = DateTime.MinValue; if (!string.IsNullOrEmpty(txt_addConDailts.Value)) { CRM_STAFF_CUSTOMER_CONTACTRECORDS c_scc = new CRM_STAFF_CUSTOMER_CONTACTRECORDS(); c_scc._Cus_ID = c_customercusid[0].Cus_Id; c_scc._SID = hid_SID.Value; c_scc._NextContactTime = DateTime.Now; c_scc._ContactTime = DateTime.Now; lastConTime = c_scc._ContactTime; c_scc._ContactRecords = txt_addConDailts.Value; c_scc._CustStatus = ddl_CusStatus.SelectedIndex; BLLTable <CRM_STAFF_CUSTOMER_CONTACTRECORDS> .Factory(conn).Insert(c_scc); } CRM_STAFF_CUSTOMER_CONTACTRECORDS c_sccNext = new CRM_STAFF_CUSTOMER_CONTACTRECORDS(); c_sccNext._Cus_ID = c_customercusid[0].Cus_Id; c_sccNext._SID = hid_SID.Value; c_sccNext._NextContactTime = DateTime.Now.AddDays(1); c_sccNext._CustStatus = ddl_CusStatus.SelectedIndex; count += BLLTable <CRM_STAFF_CUSTOMER_CONTACTRECORDS> .Factory(conn).Insert(c_sccNext); if (count < 3)//插入不成功 { lit_AddInfo.Visible = true; lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">添加失败!</a>"; return; } CRM_STAFF_CUSTOMER c_sc = new CRM_STAFF_CUSTOMER(); c_sc._Cus_ID = c_customercusid[0].Cus_Id; c_sc._SID = hid_SID.Value; c_sc._CustStatus = ddl_CusStatus.SelectedIndex; if (lastConTime != DateTime.MinValue) { c_sc._LastContactTime = lastConTime; } count += BLLTable <CRM_STAFF_CUSTOMER> .Factory(conn).Insert(c_sc); if (count < 4)//插入不成功 { lit_AddInfo.Visible = true; lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">添加失败!</a>"; return; } lit_AddInfo.Visible = true; lit_AddInfo.Text = "<a style=\"color:green; font-size:12px;\">添加成功!</a>"; ClearForm(); }
protected void Page_Load(object sender, EventArgs e) { title = valObj._ZhName + "��ϸ"; Page.Title = title; if (!IsPostBack) { try { if (!string.IsNullOrEmpty(Request["Cus_Id"])) { valObj = BLLTable<CRM_CUSTOMER>.Factory(conn).GetRowData(CRM_CUSTOMER.Attribute.Cus_Id, Request["Cus_Id"]); if(valObj==null) return ; txtCompanyName.Text = Convert.ToString(valObj.CompanyName);//Convert.ToString txtCompanyAddress.Text = Convert.ToString(valObj.CompanyAddress);//Convert.ToString txtShopName.Text = Convert.ToString(valObj.ShopName);//Convert.ToString txtShopNameURL.Text = Convert.ToString(valObj.ShopNameURL);//Convert.ToString txtCustSex.Text = Convert.ToString(valObj.CustSex);//Convert.ToInt32 txtBirthday.Text = (valObj.Birthday == DateTime.MinValue) ? "" : valObj.Birthday.ToString("yyyy-MM-dd HH:mm"); txtWangWangId.Text = Convert.ToString(valObj.WangWangId);//Convert.ToString txtCustQQ.Text = Convert.ToString(valObj.CustQQ);//Convert.ToString txtLastEditors.Text = Convert.ToString(valObj.LastEditors);//Convert.ToString txtLoadHighSeasTime.Text = (valObj.LoadHighSeasTime == DateTime.MinValue) ? "" : valObj.LoadHighSeasTime.ToString("yyyy-MM-dd HH:mm"); txtCus_Id.Text = Convert.ToString(valObj.Cus_Id);//Convert.ToInt32 } } catch (Exception ex) { litWarn.Text = ex.Message; } if (Request["ajax"] != null) { Response.Clear(); Response.Buffer = true; Response.Charset = "utf-8"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");//���������Ϊ�������� //Response.ContentType = "html/text"; this.EnableViewState = false; System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN", true); System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); divC.RenderControl(oHtmlTextWriter); Response.Write(oStringWriter.ToString()); Response.End(); } } }
protected void Page_Load(object sender, EventArgs e) { #region//默认隐藏列代码 //hideAttributeItemList = new List<AttributeItem>(); //hideAttributeItemList.Add(CRM_CUSTOMER.Attribute.EXP1); //hideAttributeItemList.Add(CRM_CUSTOMER.Attribute.EXP2); //hideAttributeItemList.Add(CRM_CUSTOMER.Attribute.EXP3); //valObj.LoadAllAttributes(true);//暂时加此代码,以后框架更新将不需要 //valObj.Remove(hideAttributeItemList); #endregion title = valObj._ZhName + "编辑"; Page.Title = title; if (!string.IsNullOrEmpty(Request["Cus_Id"])) { keyid = Request["Cus_Id"]; } if (!IsPostBack) { txtBirthday.Value = (DateTime.Now).ToString("yyyy-MM-dd"); txtLoadHighSeasTime.Value = (DateTime.Now).ToString("yyyy-MM-dd"); this.txtCus_Id.Disabled = true; this.txtCus_Id.Attributes["class"] = "dis"; try { if (keyid != "") { valObj = BLLTable <CRM_CUSTOMER> .Factory(conn).GetRowData(CRM_CUSTOMER.Attribute.Cus_Id, Request["Cus_Id"]); if (valObj == null) { return; } txtCompanyName.Value = Convert.ToString(valObj.CompanyName); //Convert.ToString txtCompanyAddress.Value = Convert.ToString(valObj.CompanyAddress); //Convert.ToString txtShopName.Value = Convert.ToString(valObj.ShopName); //Convert.ToString txtShopNameURL.Value = Convert.ToString(valObj.ShopNameURL); //Convert.ToString txtCustSex.Value = Convert.ToString(valObj.CustSex); //Convert.ToInt32 txtBirthday.Value = (valObj.Birthday == DateTime.MinValue) ? "" : valObj.Birthday.ToString("yyyy-MM-dd"); txtWangWangId.Value = Convert.ToString(valObj.WangWangId); //Convert.ToString txtCustQQ.Value = Convert.ToString(valObj.CustQQ); //Convert.ToString txtLastEditors.Value = Convert.ToString(valObj.LastEditors); //Convert.ToString txtLoadHighSeasTime.Value = (valObj.LoadHighSeasTime == DateTime.MinValue) ? "" : valObj.LoadHighSeasTime.ToString("yyyy-MM-dd"); txtCus_Id.Value = Convert.ToString(valObj.Cus_Id);//Convert.ToInt32 } } catch (Exception ex) { litWarn.Text = ex.Message; } } }
protected void btnClientToHighSeas_Click(object sender, EventArgs e) { CRM_STAFF_CUSTOMER con = new CRM_STAFF_CUSTOMER(); con._Cus_ID = Convert.ToInt32(txt_cus_id.Value); con._SID = txt_s_id.Value; int count = BLLTable<CRM_STAFF_CUSTOMER>.Factory(conn).Delete(con); CRM_STAFF_CUSTOMER_CONTACTRECORDS cval = new CRM_STAFF_CUSTOMER_CONTACTRECORDS(); cval.ID = Convert.ToDecimal(txt_ContactDetailID.Value); cval.ContactTime = DateTime.Now; cval.ContactRecords = "被" + userBase.RealName + "(" + userBase.UserID + ")抛入公海"; count += BLLTable<CRM_STAFF_CUSTOMER_CONTACTRECORDS>.Factory(conn).Update(cval, CRM_STAFF_CUSTOMER_CONTACTRECORDS.Attribute.ID); CRM_CUSTOMER ccVal = new CRM_CUSTOMER(); ccVal._Cus_Id = con._Cus_ID; ccVal._LoadHighSeasTime = DateTime.Now; count += BLLTable<CRM_CUSTOMER>.Factory(conn).Update(ccVal, CRM_CUSTOMER.Attribute.Cus_Id);//更新加入公海时间 if (count > 2) { //丢入公海成功 AgileFrame.Core.ScriptHelper.Alert(Page, "投入公海成功!"); AgileFrame.Core.ScriptHelper.CloseMe(Page); } else { //丢入公海失败 AgileFrame.Core.ScriptHelper.Alert(Page, "投入公海失败!"); return; } addCustConnDailt.Visible = false; Cus_Status.Enabled = false; Cus_Status.SelectedIndex = Convert.ToInt32(txt_cus_status.Value); btnClientToHighSeas.Visible = false; //UpdatePanel3.UpdateMode = UpdatePanelUpdateMode.Always; //UpdatePanel3.Update(); }
protected void btnFind_Click(object sender, EventArgs e) { condObj = new CRM_CUSTOMER(); if (txtCompanyName.Value != "") { condObj.Like_OR(CRM_CUSTOMER.Attribute.CompanyName, Convert.ToString(txtCompanyName.Value)); } if (txtCompanyAddress.Value != "") { condObj.Like_OR(CRM_CUSTOMER.Attribute.CompanyAddress, Convert.ToString(txtCompanyAddress.Value)); } if (txtShopName.Value != "") { condObj.Like_OR(CRM_CUSTOMER.Attribute.ShopName, Convert.ToString(txtShopName.Value)); } if (txtShopNameURL.Value != "") { condObj.Like_OR(CRM_CUSTOMER.Attribute.ShopNameURL, Convert.ToString(txtShopNameURL.Value)); } if (txtCustSex.Value != "") { condObj.Like_OR(CRM_CUSTOMER.Attribute.CustSex, Convert.ToInt32(txtCustSex.Value)); } if (txtBirthday.Value != "") { condObj.Like_OR(CRM_CUSTOMER.Attribute.Birthday, Convert.ToDateTime(txtBirthday.Value)); } if (txtWangWangId.Value != "") { condObj.Like_OR(CRM_CUSTOMER.Attribute.WangWangId, Convert.ToString(txtWangWangId.Value)); } if (txtCustQQ.Value != "") { condObj.Like_OR(CRM_CUSTOMER.Attribute.CustQQ, Convert.ToString(txtCustQQ.Value)); } if (txtLastEditors.Value != "") { condObj.Like_OR(CRM_CUSTOMER.Attribute.LastEditors, Convert.ToString(txtLastEditors.Value)); } if (txtLoadHighSeasTime.Value != "") { condObj.Like_OR(CRM_CUSTOMER.Attribute.LoadHighSeasTime, Convert.ToDateTime(txtLoadHighSeasTime.Value)); } if (txtCus_Id.Value != "") { condObj.Like_OR(CRM_CUSTOMER.Attribute.Cus_Id, Convert.ToInt32(txtCus_Id.Value)); } try { hidCondition.Value = condObj.ToJson(20); listObj = BLLTable <CRM_CUSTOMER> .Factory(conn).SelectByPage(valObj, condObj, aspPager.PageSize, 1, ref recount); repList.DataSource = listObj; repList.DataBind(); } catch (Exception ex) { litWarn.Text = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { title = valObj._ZhName + "详细"; Page.Title = title; if (!IsPostBack) { try { if (!string.IsNullOrEmpty(Request["Cus_Id"])) { valObj = BLLTable <CRM_CUSTOMER> .Factory(conn).GetRowData(CRM_CUSTOMER.Attribute.Cus_Id, Request["Cus_Id"]); if (valObj == null) { return; } txtCompanyName.Text = Convert.ToString(valObj.CompanyName);//Convert.ToString txtCompanyAddress.Text = Convert.ToString(valObj.CompanyAddress);//Convert.ToString txtShopName.Text = Convert.ToString(valObj.ShopName);//Convert.ToString txtShopNameURL.Text = Convert.ToString(valObj.ShopNameURL);//Convert.ToString txtCustSex.Text = Convert.ToString(valObj.CustSex);//Convert.ToInt32 txtBirthday.Text = (valObj.Birthday == DateTime.MinValue) ? "" : valObj.Birthday.ToString("yyyy-MM-dd HH:mm"); txtWangWangId.Text = Convert.ToString(valObj.WangWangId);//Convert.ToString txtCustQQ.Text = Convert.ToString(valObj.CustQQ);//Convert.ToString txtLastEditors.Text = Convert.ToString(valObj.LastEditors);//Convert.ToString txtLoadHighSeasTime.Text = (valObj.LoadHighSeasTime == DateTime.MinValue) ? "" : valObj.LoadHighSeasTime.ToString("yyyy-MM-dd HH:mm"); txtCus_Id.Text = Convert.ToString(valObj.Cus_Id);//Convert.ToInt32 } } catch (Exception ex) { litWarn.Text = ex.Message; } if (Request["ajax"] != null) { Response.Clear(); Response.Buffer = true; Response.Charset = "utf-8"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");//设置输出流为简体中文 //Response.ContentType = "html/text"; this.EnableViewState = false; System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN", true); System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); divC.RenderControl(oHtmlTextWriter); Response.Write(oStringWriter.ToString()); Response.End(); } } }
protected void btnCusDetailUpDown_Click(object sender, EventArgs e) { CRM_CUST c_cust = new CRM_CUST(); c_cust.Cus_ID = Convert.ToInt32(txt_cus_id.Value); c_cust.Email = page_Email.Value; c_cust.Phone = page_Phone.Value; c_cust._Cus_Name = page_Cus_Name.Value; BLLTable<CRM_CUST>.Factory(conn).Update(c_cust, CRM_CUST.Attribute.Cus_ID); CRM_CUSTOMER c_customer = new CRM_CUSTOMER(); c_customer.Cus_Id = Convert.ToInt32(txt_cus_id.Value); c_customer.CompanyAddress = page_CompanyAddress.Value; c_customer.CompanyName = page_CompanyName.Value; c_customer.ShopName = page_ShopName.Value; c_customer.ShopNameURL = page_ShopNameURL.Value; c_customer.WangWangId = page_WangWangId.Value; c_customer.CustQQ = page_CustQQ.Value; BLLTable<CRM_CUSTOMER>.Factory(conn).Update(c_customer, CRM_CUSTOMER.Attribute.Cus_Id); lit_CompanyAddress.Text = page_CompanyAddress.Value; lit_CompanyName.Text = page_CompanyName.Value; lit_ShopName.Text = page_ShopName.Value; lit_ShopNameURL.Text = page_ShopNameURL.Value; lit_WangWangId.Text = page_WangWangId.Value; lit_CustQQ.Text = page_CustQQ.Value; lit_Phone.Text = page_Phone.Value; lit_Email.Text = page_Email.Value; lit_Cus_Name.Text = page_Cus_Name.Value; }
protected void Page_Load(object sender, EventArgs e) { #region//Ĭ�������д��� //hideAttributeItemList = new List<AttributeItem>(); //hideAttributeItemList.Add(CRM_CUSTOMER.Attribute.EXP1); //hideAttributeItemList.Add(CRM_CUSTOMER.Attribute.EXP2); //hideAttributeItemList.Add(CRM_CUSTOMER.Attribute.EXP3); //valObj.LoadAllAttributes(true);//��ʱ�Ӵ˴��룬�Ժ��ܸ��½�����Ҫ //valObj.Remove(hideAttributeItemList); #endregion title = valObj._ZhName + "�༭"; Page.Title = title; if (!string.IsNullOrEmpty(Request["Cus_Id"])) { keyid = Request["Cus_Id"]; } if (!IsPostBack) { txtBirthday.Value = (DateTime.Now).ToString("yyyy-MM-dd"); txtLoadHighSeasTime.Value = (DateTime.Now).ToString("yyyy-MM-dd"); this.txtCus_Id.Disabled = true; this.txtCus_Id.Attributes["class"] = "dis"; try { if (keyid != "") { valObj = BLLTable<CRM_CUSTOMER>.Factory(conn).GetRowData(CRM_CUSTOMER.Attribute.Cus_Id, Request["Cus_Id"]); if(valObj==null) return ; txtCompanyName.Value = Convert.ToString(valObj.CompanyName);//Convert.ToString txtCompanyAddress.Value = Convert.ToString(valObj.CompanyAddress);//Convert.ToString txtShopName.Value = Convert.ToString(valObj.ShopName);//Convert.ToString txtShopNameURL.Value = Convert.ToString(valObj.ShopNameURL);//Convert.ToString txtCustSex.Value = Convert.ToString(valObj.CustSex);//Convert.ToInt32 txtBirthday.Value = (valObj.Birthday == DateTime.MinValue) ? "" : valObj.Birthday.ToString("yyyy-MM-dd"); txtWangWangId.Value = Convert.ToString(valObj.WangWangId);//Convert.ToString txtCustQQ.Value = Convert.ToString(valObj.CustQQ);//Convert.ToString txtLastEditors.Value = Convert.ToString(valObj.LastEditors);//Convert.ToString txtLoadHighSeasTime.Value = (valObj.LoadHighSeasTime == DateTime.MinValue) ? "" : valObj.LoadHighSeasTime.ToString("yyyy-MM-dd"); txtCus_Id.Value = Convert.ToString(valObj.Cus_Id);//Convert.ToInt32 } } catch (Exception ex) { litWarn.Text = ex.Message; } } }
protected void btnOK_Click(object sender, EventArgs e) { try { CRM_CUSTOMER valObj = new CRM_CUSTOMER(); if(txtCompanyName.Value !="" ) valObj.CompanyName = Convert.ToString(txtCompanyName.Value); if(txtCompanyAddress.Value !="" ) valObj.CompanyAddress = Convert.ToString(txtCompanyAddress.Value); if(txtShopName.Value !="" ) valObj.ShopName = Convert.ToString(txtShopName.Value); if(txtShopNameURL.Value !="" ) valObj.ShopNameURL = Convert.ToString(txtShopNameURL.Value); if(txtCustSex.Value !="" ) valObj.CustSex = Convert.ToInt32(txtCustSex.Value); if(txtBirthday.Value !="" ) valObj.Birthday = Convert.ToDateTime(txtBirthday.Value); if(txtWangWangId.Value !="" ) valObj.WangWangId = Convert.ToString(txtWangWangId.Value); if(txtCustQQ.Value !="" ) valObj.CustQQ = Convert.ToString(txtCustQQ.Value); if(txtLastEditors.Value !="" ) valObj.LastEditors = Convert.ToString(txtLastEditors.Value); if(txtLoadHighSeasTime.Value !="" ) valObj.LoadHighSeasTime = Convert.ToDateTime(txtLoadHighSeasTime.Value); if(txtCus_Id.Value !="" ) valObj.Cus_Id = Convert.ToInt32(txtCus_Id.Value); if (keyid != "") { valObj.Cus_Id = Convert.ToInt32(keyid); count = BLLTable<CRM_CUSTOMER>.Factory(conn).Update(valObj, CRM_CUSTOMER.Attribute.Cus_Id); } else { count = BLLTable<CRM_CUSTOMER>.Factory(conn).Insert(valObj, CRM_CUSTOMER.Attribute.Cus_Id); keyid = valObj.Cus_Id.ToString(); } if (count > 0) { StringBuilder sbData = new StringBuilder("({valObj:''"); List<AttributeItem> lstCol = valObj.af_AttributeItemList; for (int i = 0; i < lstCol.Count; i++) { object val = valObj.GetValue(lstCol[i]); if (val != null) { sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'"); } } sbData.Append("})"); Button btn = (Button)sender; if (btn.ID == "btnOK") { if (ViewState["hadSave"] == null) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = '" + sbData.ToString() + "';}else{window.returnValue = '" + sbData.ToString() + "';}window.close();", true); } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true); } } else { txtCompanyName.Value =""; txtCompanyAddress.Value =""; txtShopName.Value =""; txtShopNameURL.Value =""; txtCustSex.Value =""; txtBirthday.Value =""; txtWangWangId.Value =""; txtCustQQ.Value =""; txtLastEditors.Value =""; txtLoadHighSeasTime.Value =""; txtCus_Id.Value =""; } } } catch (Exception ex) { litWarn.Text = ex.Message; } }
protected bool CheckTheSame() { if (string.IsNullOrEmpty(txt_addMobPhone.Value) && string.IsNullOrEmpty(txt_addPhone.Value) && string.IsNullOrEmpty(txt_addQQ.Value) && string.IsNullOrEmpty(txt_addEmail.Value)) { lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">联系方式至少要填一项!</a>"; lit_AddInfo.Visible = true; return true; } CRM_CUSTOMER cctomer = new CRM_CUSTOMER(); CRM_CUST cct = new CRM_CUST(); string cctomerLike = " 1<>1 "; string cctLike = " 1<>1 "; if (!string.IsNullOrEmpty(txt_addWangWangId.Value)) { cctomerLike += " or " + CRM_CUSTOMER.Attribute.WangWangId.FieldName + " like '" + txt_addWangWangId.Value.Trim().Replace(" ", "") + "'"; } if (!string.IsNullOrEmpty(txt_addShopUrl.Value)) { txt_addShopUrl.Value = txt_addShopUrl.Value.Trim().Replace(" ", "").ToLower(); if (!txt_addShopUrl.Value.Contains(".com")) { lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">网店地址错误!</a>"; lit_AddInfo.Visible = true; return true; } int end = txt_addShopUrl.Value.IndexOf(".com") + 4; if (txt_addShopUrl.Value.Contains("://")) { int start = txt_addShopUrl.Value.IndexOf("://"); if (end - start <= 0) { lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">网店地址错误!</a>"; lit_AddInfo.Visible = true; return true; } string url = txt_addShopUrl.Value.Substring(start, end - start); cctomerLike += " or " + CRM_CUSTOMER.Attribute.ShopNameURL.FieldName + " like '%" + url + "%'"; //cctomerLike += CRM_CUSTOMER.Attribute.ShopNameURL.FieldName + " like 'http://" + txt_addShopUrl.Value.Trim().Replace(" ", "") + "%' or "; } else { string url = txt_addShopUrl.Value.Substring(0, end); cctomerLike += " or " + CRM_CUSTOMER.Attribute.ShopNameURL.FieldName + " like '" + url + "%'"; //cctomerLike += CRM_CUSTOMER.Attribute.ShopNameURL.FieldName + " like 'http://" + txt_addShopUrl.Value.Trim().Replace(" ", "") + "%' or "; } } if (!string.IsNullOrEmpty(txt_addComName.Value)) { cctomerLike += " or " + CRM_CUSTOMER.Attribute.CompanyName.FieldName + " like '" + txt_addComName.Value.Trim().Replace(" ", "") + "'"; } cctomer.Where(cctomerLike); if (!string.IsNullOrEmpty(txt_addQQ.Value)) { cctLike += " or " + CRM_CUST.Attribute.QQ.FieldName + " like '" + txt_addQQ.Value.Trim().Replace(" ", "") + "'"; } if (!string.IsNullOrEmpty(txt_addPhone.Value)) { cctLike += " or " + CRM_CUST.Attribute.Phone.FieldName + " like '" + txt_addPhone.Value.Trim().Replace(" ", "") + "'"; } if (!string.IsNullOrEmpty(txt_addMobPhone.Value)) { cctLike += " or " + CRM_CUST.Attribute.MobPhone.FieldName + " like '" + txt_addMobPhone.Value.Trim().Replace(" ", "") + "'"; } if (!string.IsNullOrEmpty(txt_addEmail.Value)) { cctLike += " or " + CRM_CUST.Attribute.Email.FieldName + " like '" + txt_addEmail.Value.Trim().Replace(" ", "") + "'"; } cct.Where(cctLike); if (BLLTable<CRM_CUSTOMER>.Exists(cctomer) || BLLTable<CRM_CUST>.Exists(cct)) { lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">添加失败!系统中存在该用户!</a>"; lit_AddInfo.Visible = true; return true; } return false; }
protected void btnSub_Click(object sender, EventArgs e) { lit_AddInfo.Text = ""; lit_AddInfo.Visible = false; CRM_STAFF_CUSTOMER cscVal = new CRM_STAFF_CUSTOMER(); cscVal._Cus_ID = 0; CRM_STAFF_CUSTOMER cscCon = new CRM_STAFF_CUSTOMER(); cscCon._SID = hid_SID.Value; List<CRM_STAFF_CUSTOMER> cscList = BLLTable<CRM_STAFF_CUSTOMER>.Factory(conn).Select(cscVal, cscCon); if (cscList.Count >= 500) { lit_AddInfo.Visible = true; lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">添加失败!客户数达到上限500个。</a>"; return; } if (CheckTheSame()) { return; } CRM_CUSTOMER c_customer = new CRM_CUSTOMER(); if (!string.IsNullOrEmpty(txt_addComAddress.Value)) c_customer.CompanyAddress = txt_addComAddress.Value.Trim().Replace(" ", ""); c_customer._CustSex = txt_addCustSexMan.Checked ? 1 : 0; if (!string.IsNullOrEmpty(txt_addShopName.Value)) c_customer._ShopName = txt_addShopName.Value.Trim().Replace(" ", ""); if (!string.IsNullOrEmpty(txt_addShopUrl.Value)) c_customer._ShopNameURL = txt_addShopUrl.Value.Trim().Replace(" ", ""); if (!string.IsNullOrEmpty(txt_addWangWangId.Value)) c_customer._WangWangId = txt_addWangWangId.Value.Trim().Replace(" ", ""); if (!string.IsNullOrEmpty(txt_addComName.Value)) c_customer._CompanyName = txt_addComName.Value.Trim().Replace(" ", ""); else c_customer._CompanyName = txt_addShopName.Value.Trim().Replace(" ", ""); c_customer._LastEditors = hid_SID.Value; int count = BLLTable<CRM_CUSTOMER>.Factory(conn).Insert(c_customer); if (count < 1)//插入不成功 { lit_AddInfo.Visible = true; lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">添加失败!</a>"; return; } c_customer.OrderBy(CRM_CUSTOMER.Attribute.Cus_Id, Order.Desc); c_customer.Top(1); CRM_CUSTOMER c_customerval = new CRM_CUSTOMER(); c_customerval.Cus_Id = 0; List<CRM_CUSTOMER> c_customercusid = BLLTable<CRM_CUSTOMER>.Factory(conn).Select(c_customerval, c_customer); if (c_customercusid.Count < 1)//插入不成功? { lit_AddInfo.Visible = true; lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">添加失败!</a>"; return; } CRM_CUST c_cust = new CRM_CUST(); c_cust._Cus_ID = c_customercusid[0].Cus_Id; if (!string.IsNullOrEmpty(txt_addCustName.Value)) c_cust._Cus_Name = txt_addCustName.Value.Trim().Replace(" ", ""); if (!string.IsNullOrEmpty(txt_addEmail.Value)) c_cust._Email = txt_addEmail.Value.Trim().Replace(" ", ""); if (!string.IsNullOrEmpty(txt_addMobPhone.Value)) c_cust._MobPhone = txt_addMobPhone.Value.Trim().Replace(" ", ""); if (!string.IsNullOrEmpty(txt_addPhone.Value)) c_cust._Phone = txt_addPhone.Value.Trim().Replace(" ", ""); if (!string.IsNullOrEmpty(txt_addQQ.Value)) c_cust._QQ = txt_addQQ.Value.Trim().Replace(" ", ""); if (!string.IsNullOrEmpty(txt_addCustName.Value)) c_cust._ContactName = txt_addCustName.Value.Trim().Replace(" ", ""); c_cust._AddTime = DateTime.Now; c_cust._EditTime = DateTime.Now; count += BLLTable<CRM_CUST>.Factory(conn).Insert(c_cust); if (count < 2)//插入不成功 { lit_AddInfo.Visible = true; lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">添加失败!</a>"; return; } if (string.IsNullOrEmpty(hid_SID.Value)) return; DateTime lastConTime = DateTime.MinValue; if (!string.IsNullOrEmpty(txt_addConDailts.Value)) { CRM_STAFF_CUSTOMER_CONTACTRECORDS c_scc = new CRM_STAFF_CUSTOMER_CONTACTRECORDS(); c_scc._Cus_ID = c_customercusid[0].Cus_Id; c_scc._SID = hid_SID.Value; c_scc._NextContactTime = DateTime.Now; c_scc._ContactTime = DateTime.Now; lastConTime = c_scc._ContactTime; c_scc._ContactRecords = txt_addConDailts.Value; c_scc._CustStatus = ddl_CusStatus.SelectedIndex; BLLTable<CRM_STAFF_CUSTOMER_CONTACTRECORDS>.Factory(conn).Insert(c_scc); } CRM_STAFF_CUSTOMER_CONTACTRECORDS c_sccNext = new CRM_STAFF_CUSTOMER_CONTACTRECORDS(); c_sccNext._Cus_ID = c_customercusid[0].Cus_Id; c_sccNext._SID = hid_SID.Value; c_sccNext._NextContactTime = DateTime.Now.AddDays(1); c_sccNext._CustStatus = ddl_CusStatus.SelectedIndex; count += BLLTable<CRM_STAFF_CUSTOMER_CONTACTRECORDS>.Factory(conn).Insert(c_sccNext); if (count < 3)//插入不成功 { lit_AddInfo.Visible = true; lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">添加失败!</a>"; return; } CRM_STAFF_CUSTOMER c_sc = new CRM_STAFF_CUSTOMER(); c_sc._Cus_ID = c_customercusid[0].Cus_Id; c_sc._SID = hid_SID.Value; c_sc._CustStatus = ddl_CusStatus.SelectedIndex; if (lastConTime != DateTime.MinValue) c_sc._LastContactTime = lastConTime; count += BLLTable<CRM_STAFF_CUSTOMER>.Factory(conn).Insert(c_sc); if (count < 4)//插入不成功 { lit_AddInfo.Visible = true; lit_AddInfo.Text = "<a style=\"color:red; font-size:12px;\">添加失败!</a>"; return; } lit_AddInfo.Visible = true; lit_AddInfo.Text = "<a style=\"color:green; font-size:12px;\">添加成功!</a>"; ClearForm(); }
protected void Page_Load(object sender, EventArgs e) { #region//Ĭ�����ص��� //hideTableColumnList = new List<AttributeItem>(); //hideTableColumnList.Add(CRM_CUSTOMER.Attribute.EXP1); //hideTableColumnList.Add(CRM_CUSTOMER.Attribute.EXP2); //hideTableColumnList.Add(CRM_CUSTOMER.Attribute.EXP3); //valObj.LoadAllAttributes(true);//��ʱ�Ӵ˴��룬�Ժ��ܸ��½�����Ҫ //valObj.Remove(hideTableColumnList); //hideFindColumnList = new List<AttributeItem>(); //hideFindColumnList.Add(CRM_CUSTOMER.Attribute.EXP1); //hideFindColumnList.Add(CRM_CUSTOMER.Attribute.EXP2); //hideFindColumnList.Add(CRM_CUSTOMER.Attribute.EXP3); #endregion condObj.OrderBy(CRM_CUSTOMER.Attribute.Cus_Id, Order.Desc); if (!IsPostBack) { btnFind.Text = LanguageService.GetLanguageString("btnFind", "��ѯ"); aspPager.PageSize = 10; aspPager.CurrentPageIndex = 1; if (!string.IsNullOrEmpty(Request["ids"])) { CRM_CUSTOMER roleOld = new CRM_CUSTOMER(); roleOld.Where(CRM_CUSTOMER.Attribute.Cus_Id, Request["ids"].ToString()); listObj = BLLTable<CRM_CUSTOMER>.Factory(conn).Select(valObj, roleOld); for (int i = 0; i < listObj.Count; i++) { if (i > 0) { hidOld.Value += ","; hidInitIDS.Value += ","; } hidOld.Value += "{ID:'" + listObj[i].Cus_Id + "',Name:'" + listObj[i].Cus_Id + "'}";//�����Name������ʾ���б��У��������ض��塣 hidInitIDS.Value += listObj[i].Cus_Id; } } try { listObj = BLLTable<CRM_CUSTOMER>.Factory(conn).SelectByPage(valObj, condObj, aspPager.PageSize, 1, ref recount); repList.DataSource = listObj; repList.DataBind(); aspPager.RecordCount = recount; } catch (Exception ex) { litWarn.Text = ex.Message; } } }