Пример #1
0
    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;
            }
        }
    }
Пример #2
0
    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();
    }
Пример #3
0
    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();
    }