Exemple #1
0
        private void BindData()
        {
            UDS.Components.CM cm = new UDS.Components.CM();
            UDS.Components.ClientInfo client = new UDS.Components.ClientInfo();
            SqlDataReader dr = null;
            clientid = ((Request.Params["clientid"]==null)||(Request.Params["clientid"].ToString().Trim()==""))?0:Int32.Parse(Request.Params["clientid"]);
            if(clientid!=0)
            {
                dr = cm.GetLinkmanFromClient(clientid);
                client = cm.GetClientAllInfo(clientid);
            }
            else //���û�д���clientid��ô����Ƿ�����ʱlinkman
            {
                string linkmanstring = (Session["tmplinkmanid"]==null)?"0":Session["tmplinkmanid"].ToString();
                if(linkmanstring.EndsWith(","))
                    linkmanstring = linkmanstring.Substring(0,linkmanstring.Length-1);
                dr = cm.GetLinkmanByID(linkmanstring);
            }
            //			rbl_LinkmanList.DataSource = dr;
            //			rbl_LinkmanList.DataTextField = "Name";
            //			rbl_LinkmanList.DataValueField = "id";
            //			rbl_LinkmanList.DataBind();
            while(dr.Read())
            {
                ListItem li = new ListItem();
                if(Session["cm_permission"].ToString()=="administrator")
                    li.Text = "<a href='Linkman.aspx?LinkmanID="+dr["ID"].ToString()+"'>"+dr["Name"].ToString()+"</a>";
                else
                    li.Text = dr["Name"].ToString();

                li.Value = dr["ID"].ToString();
                rbl_LinkmanList.Items.Add(li);

            }
            dr.Close();
            //�����ʱ��Ҫ��ϵ�˴�������������ѡ��״̬
            if(Session["tmpchief"]!=null)
            {
                //�ҵ�tmpchief��indexֵ����������ѡ��״̬
                foreach(ListItem lt in rbl_LinkmanList.Items)
                {
                    if(lt.Value == Session["tmpchief"].ToString())
                        lt.Selected = true;
                }
            }
            else
            {
                foreach(ListItem lt in rbl_LinkmanList.Items)
                {
                    if(lt.Value == client.ChiefLinkmanID.ToString())
                        lt.Selected = true;
                }
            }
        }
Exemple #2
0
        private void btn_ChangeAddMan_Click(object sender, System.EventArgs e)
        {
            UDS.Components.CM         cm     = new UDS.Components.CM();
            UDS.Components.ClientInfo client = cm.GetClientAllInfo(clientid);
            if (Page.IsValid)
            {
                client.AddManID = Int32.Parse(ddl_AddMan.SelectedItem.Value);
                cm.UpdateClient(client);
                //判断权限
                if (ddl_AddMan.SelectedItem.Value == Request.Cookies["UserID"].Value)
                {
                    Session["cm_permission"] = "administrator";
                }
                else
                {
                    Session["cm_permission"] = "leader";
                }

                Response.Write("<script>alert('修改成功!');opener.location.href='ClientListView.aspx';close();</script>");
            }
        }
Exemple #3
0
        private void btn_OK_Click(object sender, System.EventArgs e)
        {
            UDS.Components.CM         cm     = new UDS.Components.CM();
            UDS.Components.ClientInfo client = cm.GetClientAllInfo(clientid);
            if (Page.IsValid)
            {
                #region 填充client结构
                client.ClientShortName = tbx_ShortName.Text;
                client.ClientName      = tbx_Name.Text;
                client.AddManID        = Int32.Parse(Request.Cookies["UserID"].Value);
                client.UpdateTime      = DateTime.Parse(tbx_UpdateTime.Text);
                client.Affiliatedarea  = tbx_affiliatedarea.Text;
                client.URL             = tbx_URL.Text;
                client.ZIP             = tbx_zip.Text;
                client.Address         = tbx_address.Text;
                client.Type            = "";

                if (cbx_zhongduan.Checked)
                {
                    client.Type += ClientType.terminal.ToString() + ",";
                }
                if (cbx_qudao.Checked)
                {
                    client.Type += ClientType.channal.ToString() + ",";
                }
                if (cbx_shehui.Checked)
                {
                    client.Type += ClientType.social.ToString() + ",";
                }
                if (cbx_meiti.Checked)
                {
                    client.Type += ClientType.media.ToString() + ",";
                }

                client.EnterpriseType = "";
                if (cbx_government.Checked)
                {
                    client.EnterpriseType += EnterpriseType.government.ToString() + ",";
                }
                if (cbx_stateowned.Checked)
                {
                    client.EnterpriseType += EnterpriseType.contry.ToString() + ",";
                }
                if (cbx_private.Checked)
                {
                    client.EnterpriseType += EnterpriseType.privateowned.ToString() + ",";
                }
                if (cbx_foreign.Checked)
                {
                    client.EnterpriseType += EnterpriseType.oversea.ToString() + ",";
                }

                if (cbx_market.Checked)
                {
                    client.EnterpriseType += EnterpriseType.stock.ToString() + ",";
                }

                client.Calling = "";
                if (cbx_realestate.Checked)
                {
                    client.Calling += ClientTrade.realty.ToString() + ",";
                }
                if (cbx_IT.Checked)
                {
                    client.Calling += ClientTrade.IT.ToString() + ",";
                }
                if (cbx_business.Checked)
                {
                    client.Calling += ClientTrade.business.ToString() + ",";
                }
                if (cbx_telecom.Checked)
                {
                    client.Calling += ClientTrade.telecom.ToString() + ",";
                }
                if (cbx_post.Checked)
                {
                    client.Calling += ClientTrade.post.ToString() + ",";
                }
                if (cbx_consultation.Checked)
                {
                    client.Calling += ClientTrade.refer.ToString() + ",";
                }
                if (cbx_travel.Checked)
                {
                    client.Calling += ClientTrade.travel.ToString() + ",";
                }
                if (cbx_bus.Checked)
                {
                    client.Calling += ClientTrade.bus.ToString() + ",";
                }
                if (cbx_stock.Checked)
                {
                    client.Calling += ClientTrade.stock.ToString() + ",";
                }
                if (cbx_insurance.Checked)
                {
                    client.Calling += ClientTrade.insurance.ToString() + ",";
                }
                if (cbx_tax.Checked)
                {
                    client.Calling += ClientTrade.tax.ToString() + ",";
                }
                if (cbx_make.Checked)
                {
                    client.Calling += ClientTrade.make.ToString() + ",";
                }
                if (cbx_electric.Checked)
                {
                    client.Calling += ClientTrade.he.ToString() + ",";
                }
                if (cbx_clothe.Checked)
                {
                    client.Calling += ClientTrade.clothe.ToString() + ",";
                }
                if (cbx_food.Checked)
                {
                    client.Calling += ClientTrade.food.ToString() + ",";
                }
                if (cbx_medicine.Checked)
                {
                    client.Calling += ClientTrade.medicine.ToString() + ",";
                }
                if (cbx_mechanism.Checked)
                {
                    client.Calling += ClientTrade.mechanism.ToString() + ",";
                }
                if (cbx_auto.Checked)
                {
                    client.Calling += ClientTrade.auto.ToString() + ",";
                }

                client.CompanySize = tbx_staffnumber.Text;
                client.Money       = tbx_money.Text;
                client.Operation   = tbx_operation.Text;
                client.Introduce   = tbx_introduce.Text;
                client.ITGrade     = tbx_IT.Text;
                client.PCNumber    = Int32.Parse(tbx_pcnumber.Text);

                client.Net = "";
                if (cbx_LAN.Checked)
                {
                    client.Net += ClientNet.LAN.ToString() + ",";
                }
                if (cbx_WAN.Checked)
                {
                    client.Net += ClientNet.WAN.ToString() + ",";
                }
                if (cbx_internet.Checked)
                {
                    client.Net += ClientNet.INTERNET.ToString() + ",";
                }
                client.ITStaffs     = Int32.Parse(tbx_ITStaffs.Text);
                client.ITDepartment = tbx_ITdepartment.Text;
                client.Principal    = tbx_principal.Text;
                client.System       = tbx_system.Text;

                client.ClientSource = "";
                if (cbx_sellman.Checked)
                {
                    client.ClientSource += ClientSource.sellman + ",";
                }
                if (cbx_just.Checked)
                {
                    client.ClientSource += ClientSource.familiar + ",";
                }
                if (cbx_introduce.Checked)
                {
                    client.ClientSource += ClientSource.introduce + ",";
                }
                if (cbx_customer.Checked)
                {
                    client.ClientSource += ClientSource.client + ",";
                }

                client.ClientInitiative = "";
                if (cbx_media.Checked)
                {
                    client.ClientInitiative += ClientInitiative.media + ",";
                }
                if (cbx_Web.Checked)
                {
                    client.ClientInitiative += ClientInitiative.searchweb + ",";
                }
                if (cbx_proseminar.Checked)
                {
                    client.ClientInitiative += ClientInitiative.proseminar + ",";
                }
                if (cbx_exhibition.Checked)
                {
                    client.ClientInitiative += ClientInitiative.exhibition + ",";
                }
                if (cbx_EMS.Checked)
                {
                    client.ClientInitiative += ClientInitiative.post + ",";
                }
                if (cbx_Email.Checked)
                {
                    client.ClientInitiative += ClientInitiative.email + ",";
                }
                #endregion

                client.ChiefLinkmanID = (Session["tmpchief"] == null)?0:Int32.Parse(Session["tmpchief"].ToString());

                //根据clientid==0判断是update还是add
                try
                {
                    if (clientid != 0)                  //修改
                    {
                        SqlDataReader dr_chief = cm.GetLinkmanByID(client.ChiefLinkmanID.ToString());
                        while (dr_chief.Read())
                        {
                            if (Session["cm_permission"].ToString() == "administrator")
                            {
                                hlk_Chiefman.Text        = dr_chief["name"].ToString();
                                hlk_Chiefman.NavigateUrl = "Linkman.aspx?LinkmanID=" + dr_chief["id"].ToString();
                                hlk_Chiefman.Target      = "_blank";
                            }
                            else
                            {
                                hlk_Chiefman.Text = dr_chief["name"].ToString();
                            }
                        }
                        dr_chief.Close();
                        cm.UpdateClient(client);
                        Response.Write("<script>alert('修改成功!');opener.location.href=opener.location.href;close();</script>");
                    }
                    else                     //新增
                    {
                        CustomValidator1.Enabled = true;
                        CustomValidator1.Validate();
                        string tmplinkmanid = (Session["tmplinkmanid"] == null)?"":Session["tmplinkmanid"].ToString();
                        client.Birthday       = DateTime.Now;
                        client.ID             = cm.AddClinet(client);
                        ViewState["ClientID"] = client.ID.ToString();
                        ltl_ID.Text           = client.ID.ToString();
                        clientid = client.ID;
                        SqlDataReader dr_chief = cm.GetLinkmanByID(client.ChiefLinkmanID.ToString());
                        while (dr_chief.Read())
                        {
                            if (Session["cm_permission"].ToString() == "administrator")
                            {
                                hlk_Chiefman.Text        = dr_chief["name"].ToString();
                                hlk_Chiefman.NavigateUrl = "Linkman.aspx?LinkmanID=" + dr_chief["id"].ToString();
                                hlk_Chiefman.Target      = "_blank";
                            }
                            else
                            {
                                hlk_Chiefman.Text = dr_chief["name"].ToString();
                            }
                            lbl_position.Text = dr_chief["Position"].ToString();
                            lbl_chieftel.Text = dr_chief["Telephone"].ToString();
                        }
                        dr_chief.Close();
                        //分析session中的tmplinkmanid使他们得到clientid
                        foreach (string linkmanid in tmplinkmanid.Split(','))
                        {
                            if (linkmanid.Trim() != "")
                            {
                                UDS.Components.Linkman linkman = new UDS.Components.Linkman();
                                UDS.Components.CM      cm1     = new UDS.Components.CM();
                                linkman          = cm1.GetLinkmanStructByID(linkmanid);
                                linkman.ClientID = client.ID;
                                linkman.ID       = Int32.Parse(linkmanid);
                                cm.UpdateLinkman(linkman);
                            }
                        }
                        //清空Session
                        Session.Remove("tmpchief");
                        Session.Remove("tmplinkmanid");
                        Response.Write("<script>alert('添加成功!');opener.location.href=opener.location.href;close();</script>");
                    }
                }
                catch (Exception ex)
                {
                    UDS.Components.Error.Log(ex.Message);
                    Server.Transfer("../Error.aspx");
                }
                //Response.Write("<script>if(opener!=null) opener.location.reload();</script>");
                //刷新页面显示
                if (clientid == 0)
                {
                    btn_AddContact.Visible = false;
                }
                else
                {
                    btn_AddContact.Visible = true;
                }

                penal.Visible = cbx_customer.Checked;

                //上传附件
                UploadAtt();

                //显示附件
                if (clientid != 0)
                {
                    rpt_Attachment.DataSource = cm.GetAttachmentByClientID(clientid);
                    rpt_Attachment.DataBind();
                }
            }
        }
Exemple #4
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            UDS.Components.CM cm = new UDS.Components.CM();

            if (!Page.IsPostBack)
            {
                tbx_UpdateTime.Text = DateTime.Now.ToShortDateString();
                //得到添加人的信息
                UDS.Components.Staff staff = new UDS.Components.Staff();

                #region 显示客户原有信息
                UDS.Components.ClientInfo client = cm.GetClientAllInfo((Request.QueryString["ClientID"] == null)?0:Int32.Parse(Request.QueryString["ClientID"].ToString()));
                ViewState["ClientID"] = client.ID;
                clientid = client.ID;

                /* 权限判断
                 * 如果是上级则出现下拉菜单,并可重新指定客户经理
                 * 其它则无下拉菜单
                 */
                if (Session["cm_permission"].ToString() == "leader")
                {
                    //绑定下拉列表
                    pnl_Leader.Visible     = true;
                    ltl_AddManName.Visible = ltl_addmantel.Visible = false;
                    //不出现修改按钮
                    pnl_MyCustom.Visible = false;
                    pnl_Leader1.Visible  = true;

                    BindAddManList();
                    //添加人默认选中
                    ddl_AddMan.Items.FindByValue(client.AddManID.ToString()).Selected = true;
                }
                else
                {
                    pnl_Leader.Visible     = false;
                    ltl_AddManName.Visible = ltl_addmantel.Visible = true;
                    SqlDataReader dr_staff = null;

                    if (client.ID != 0)
                    {
                        dr_staff = staff.GetStaffInfo(client.AddManID);
                        while (dr_staff.Read())
                        {
                            ltl_AddManName.Text = dr_staff["realname"].ToString();
                            ltl_addmantel.Text  = dr_staff["Mobile"].ToString();
                        }
                    }
                    else
                    {
                        dr_staff = staff.GetStaffInfo(Int32.Parse(Request.Cookies["UserID"].Value));
                        while (dr_staff.Read())
                        {
                            ltl_AddManName.Text = dr_staff["realname"].ToString();
                            ltl_addmantel.Text  = dr_staff["Mobile"].ToString();
                        }
                    }
                    dr_staff.Close();
                }


                ltl_ID.Text        = (client.ID.ToString() == "0")?"":client.ID.ToString();
                tbx_ShortName.Text = client.ClientShortName;
                tbx_Name.Text      = client.ClientName;
                if (clientid != 0)
                {
                    tbx_Birthday.Text = client.Birthday.ToShortDateString();
                }
                else
                {
                    tbx_Birthday.Text = DateTime.Now.ToShortDateString();
                }

                if (client.ClientType.IndexOf(ClientType.terminal.ToString()) >= 0)
                {
                    cbx_zhongduan.Checked = true;
                }
                if (client.ClientType.IndexOf(ClientType.channal.ToString()) >= 0)
                {
                    cbx_qudao.Checked = true;
                }
                if (client.ClientType.IndexOf(ClientType.social.ToString()) >= 0)
                {
                    cbx_shehui.Checked = true;
                }
                if (client.ClientType.IndexOf(ClientType.media.ToString()) >= 0)
                {
                    cbx_meiti.Checked = true;
                }
                //得到主要联系人的信息
                SqlDataReader dr_chief = cm.GetLinkmanByID(client.ChiefLinkmanID.ToString());
                while (dr_chief.Read())
                {
                    if (Session["cm_permission"].ToString() == "administrator")
                    {
                        hlk_Chiefman.Text        = dr_chief["name"].ToString();
                        hlk_Chiefman.NavigateUrl = "Linkman.aspx?LinkmanID=" + dr_chief["id"].ToString();
                        hlk_Chiefman.Target      = "_blank";
                    }
                    else
                    {
                        hlk_Chiefman.Text = dr_chief["name"].ToString();
                    }

                    lbl_position.Text = dr_chief["position"].ToString();
                    lbl_chieftel.Text = dr_chief["telephone"].ToString();
                }
                dr_chief.Close();
                tbx_affiliatedarea.Text = client.Affiliatedarea;
                tbx_URL.Text            = client.URL;
                tbx_zip.Text            = client.ZIP;
                tbx_address.Text        = client.Address;

                if (client.CompanyProperty.IndexOf(EnterpriseType.government.ToString()) >= 0)
                {
                    cbx_government.Checked = true;
                }
                if (client.CompanyProperty.IndexOf(EnterpriseType.contry.ToString()) >= 0)
                {
                    cbx_stateowned.Checked = true;
                }
                if (client.CompanyProperty.IndexOf(EnterpriseType.privateowned.ToString()) >= 0)
                {
                    cbx_private.Checked = true;
                }
                if (client.CompanyProperty.IndexOf(EnterpriseType.oversea.ToString()) >= 0)
                {
                    cbx_foreign.Checked = true;
                }
                if (client.CompanyProperty.IndexOf(EnterpriseType.stock.ToString()) >= 0)
                {
                    cbx_market.Checked = true;
                }

                if (client.ClientTrade.IndexOf(ClientTrade.realty.ToString()) >= 0)
                {
                    cbx_realestate.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.IT.ToString()) >= 0)
                {
                    cbx_IT.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.business.ToString()) >= 0)
                {
                    cbx_business.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.telecom.ToString()) >= 0)
                {
                    cbx_telecom.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.post.ToString()) >= 0)
                {
                    cbx_post.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.refer.ToString()) >= 0)
                {
                    cbx_consultation.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.travel.ToString()) >= 0)
                {
                    cbx_travel.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.bus.ToString()) >= 0)
                {
                    cbx_bus.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.stock.ToString()) >= 0)
                {
                    cbx_stock.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.insurance.ToString()) >= 0)
                {
                    cbx_insurance.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.tax.ToString()) >= 0)
                {
                    cbx_tax.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.make.ToString()) >= 0)
                {
                    cbx_make.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.he.ToString()) >= 0)
                {
                    cbx_electric.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.clothe.ToString()) >= 0)
                {
                    cbx_clothe.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.food.ToString()) >= 0)
                {
                    cbx_food.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.medicine.ToString()) >= 0)
                {
                    cbx_medicine.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.mechanism.ToString()) >= 0)
                {
                    cbx_mechanism.Checked = true;
                }
                if (client.ClientTrade.IndexOf(ClientTrade.auto.ToString()) >= 0)
                {
                    cbx_auto.Checked = true;
                }

                tbx_staffnumber.Text = client.CompanySize;
                tbx_money.Text       = client.Money;
                tbx_operation.Text   = client.Operation;
                tbx_introduce.Text   = client.Introduce;
                tbx_IT.Text          = client.ITGrade;
                tbx_pcnumber.Text    = client.PCNumber.ToString();

                if (client.Net.IndexOf(ClientNet.LAN.ToString()) >= 0)
                {
                    cbx_LAN.Checked = true;
                }
                if (client.Net.IndexOf(ClientNet.WAN.ToString()) >= 0)
                {
                    cbx_WAN.Checked = true;
                }
                if (client.Net.IndexOf(ClientNet.INTERNET.ToString()) >= 0)
                {
                    cbx_internet.Checked = true;
                }

                tbx_ITStaffs.Text     = client.ITStaffs.ToString();
                tbx_ITdepartment.Text = client.ITDepartment;
                tbx_principal.Text    = client.Principal;
                tbx_system.Text       = client.System;

                if (client.ClientSource.IndexOf(ClientSource.sellman.ToString()) >= 0)
                {
                    cbx_sellman.Checked = true;
                }
                if (client.ClientSource.IndexOf(ClientSource.familiar.ToString()) >= 0)
                {
                    cbx_just.Checked = true;
                }
                if (client.ClientSource.IndexOf(ClientSource.introduce.ToString()) >= 0)
                {
                    cbx_introduce.Checked = true;
                }
                if (client.ClientSource.IndexOf(ClientSource.client.ToString()) >= 0)
                {
                    cbx_customer.Checked = true;
                }

                if (client.ClientInitiative.IndexOf(ClientInitiative.media.ToString()) >= 0)
                {
                    cbx_media.Checked = true;
                }
                if (client.ClientInitiative.IndexOf(ClientInitiative.searchweb.ToString()) >= 0)
                {
                    cbx_Web.Checked = true;
                }
                if (client.ClientInitiative.IndexOf(ClientInitiative.proseminar.ToString()) >= 0)
                {
                    cbx_proseminar.Checked = true;
                }
                if (client.ClientInitiative.IndexOf(ClientInitiative.exhibition.ToString()) >= 0)
                {
                    cbx_exhibition.Checked = true;
                }
                if (client.ClientInitiative.IndexOf(ClientInitiative.post.ToString()) >= 0)
                {
                    cbx_EMS.Checked = true;
                }
                if (client.ClientInitiative.IndexOf(ClientInitiative.email.ToString()) >= 0)
                {
                    cbx_Email.Checked = true;
                }
                #endregion

                if (clientid == 0)
                {
                    btn_OK.Text = "添加";
                    CustomValidator1.Enabled = true;
                }
                else
                {
                    btn_OK.Text = "修改";
                    CustomValidator1.Enabled = false;
                }

                penal.Visible = cbx_customer.Checked;
            }
            else
            {
                clientid = Int32.Parse(ViewState["ClientID"].ToString());

                //显示联系人
                string tmplinkmanid1 = (Session["tmplinkmanid"] == null)?"":Session["tmplinkmanid"].ToString();
                foreach (string linkmanid in tmplinkmanid1.Split(','))
                {
                    if (linkmanid.Trim() != "")
                    {
                        UDS.Components.Linkman linkman = new UDS.Components.Linkman();
                        UDS.Components.CM      cm1     = new UDS.Components.CM();
                        linkman = cm1.GetLinkmanStructByID(linkmanid);

                        if (Session["cm_permission"].ToString() == "administrator")
                        {
                            hlk_Chiefman.Text        = linkman.Name;
                            hlk_Chiefman.NavigateUrl = "Linkman.aspx?LinkmanID=" + linkman.ID;
                            hlk_Chiefman.Target      = "_blank";
                        }
                        else
                        {
                            hlk_Chiefman.Text = linkman.Name;;
                        }

                        lbl_position.Text = linkman.Position;
                        lbl_chieftel.Text = linkman.Telephone;
                    }
                }
            }

            if (clientid != 0)
            {
                rpt_Attachment.DataSource = cm.GetAttachmentByClientID(clientid);
                rpt_Attachment.DataBind();
            }

            if (clientid == 0)
            {
                btn_AddContact.Visible = false;
            }
            else
            {
                btn_AddContact.Visible = true;
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            // 在此处放置用户代码以初始化页面
            UDS.Components.CM cm = new UDS.Components.CM();
            SqlDataReader     dr = null;

            if (!Page.IsPostBack)
            {
                tbx_contacttime.Text     = DateTime.Now.ToShortDateString();
                tbx_nextcontacttime.Text = DateTime.Now.AddDays(1).ToShortDateString();
                clientid = Int32.Parse((Request.QueryString["ClientID"] == null) || (Request.QueryString["ClientID"] == "")?"-1":Request.QueryString["ClientID"].ToString());

                pnl_clientselect.Visible = true;
                //绑定客户列表
                dr = cm.GetMyClients(Int32.Parse(Request.Cookies["UserID"].Value));
                ddl_ClientName.DataSource     = dr;
                ddl_ClientName.DataValueField = "id";
                ddl_ClientName.DataTextField  = "name";
                ddl_ClientName.DataBind();
                dr.Close();
                if (clientid != -1)
                {
                    if (ddl_ClientName.Items.Count != 0)
                    {
                        foreach (ListItem li in ddl_ClientName.Items)
                        {
                            if (li.Value == clientid.ToString())
                            {
                                li.Selected = true;
                            }
                            else
                            {
                                li.Selected = false;
                            }
                        }
                        ViewState["ClientID"] = clientid;
                    }
                    //显示销售人员
                    UDS.Components.ClientInfo client   = cm.GetClientAllInfo(clientid);
                    UDS.Components.Staff      staff    = new UDS.Components.Staff();
                    SqlDataReader             dr_staff = staff.GetStaffInfo(client.AddManID);
                    while (dr_staff.Read())
                    {
                        ltl_AddMan.Text = dr_staff["realname"].ToString();
                    }
                    dr_staff.Close();
                }
                else
                {
                    if (ddl_ClientName.Items.Count != 0)
                    {
                        clientid = Int32.Parse(ddl_ClientName.Items[0].Value);
                        ViewState["ClientID"] = clientid;
                    }
                    else
                    {
                        ViewState["ClientID"] = clientid;
                    }
                }
                DisplayClientInfo();
                BindData();
                ViewState["ContactID"] = contactid.ToString();
            }
            else
            {
                clientid  = Int32.Parse(ViewState["ClientID"].ToString());
                contactid = Int32.Parse(ViewState["ContactID"].ToString());
            }
            //tbx_contacttime.Attributes["onfocus"] = "setday(this)";
            //tbx_nextcontacttime.Attributes["onfocus"] = "setday(this)";
        }
        private void btn_OK_Click(object sender, System.EventArgs e)
        {
            UDS.Components.CM         cm      = new UDS.Components.CM();
            UDS.Components.Contact    contact = new UDS.Components.Contact();
            UDS.Components.ClientInfo client  = cm.GetClientAllInfo(clientid);
            //添加协同人员
            foreach (ListItem lt in lbx_Cooperater.Items)
            {
                UDS.Components.Cooperater cooperater = new UDS.Components.Cooperater();
                cooperater.StaffID = Int32.Parse(lt.Value);
                contact.AddCooperater(cooperater);
            }
            //添加联系人员
            foreach (ListItem lt in lbx_Linkman.Items)
            {
                UDS.Components.Linkman linkman = new UDS.Components.Linkman();
                linkman.ID = Int32.Parse(lt.Value);
                contact.AddLinkman(linkman);
            }

            contact.ID = contactid;

            #region 填充contact
            contact.UpdateTime       = DateTime.Now;
            contact.ContactTimes     = Int32.Parse(ltl_ContactTimes.Text);
            contact.StaffID          = client.AddManID;
            contact.ContactTime      = DateTime.Parse(tbx_contacttime.Text);
            contact.ClientID         = clientid;
            contact.ContactAim       = tbx_contactaim.Text;
            contact.SellMoney        = tbx_sellmoney.Text;
            contact.BargainPrognosis = ddl_bargainprognosis.SelectedItem.Value;
            if (cbx_telephone.Checked)
            {
                contact.ContactType += ContactType.telephone.ToString() + ",";
            }
            if (cbx_fax.Checked)
            {
                contact.ContactType += ContactType.fax.ToString() + ",";
            }
            if (cbx_email.Checked)
            {
                contact.ContactType += ContactType.email.ToString() + ",";
            }
            if (cbx_mail.Checked)
            {
                contact.ContactType += ContactType.mail.ToString() + ",";
            }
            if (cbx_sms.Checked)
            {
                contact.ContactType += ContactType.sms.ToString() + ",";
            }
            if (cbx_callin.Checked)
            {
                contact.ContactType += ContactType.interview.ToString() + ",";
            }
            if (cbx_meeting.Checked)
            {
                contact.ContactType += ContactType.meeting.ToString() + ",";
            }

            if (rbtn_trace.Checked)
            {
                contact.ContactStatus += ContactStat.trace.ToString() + ",";
            }
            if (rbtn_boot.Checked)
            {
                contact.ContactStatus += ContactStat.boot.ToString() + ",";
            }
            if (rbtn_commend.Checked)
            {
                contact.ContactStatus += ContactStat.commend.ToString() + ",";
            }
            if (rbtn_requirement.Checked)
            {
                contact.ContactStatus += ContactStat.requirement.ToString() + ",";
            }
            if (rbtn_submit.Checked)
            {
                contact.ContactStatus += ContactStat.submit.ToString() + ",";
            }
            if (rbtn_negotiate.Checked)
            {
                contact.ContactStatus += ContactStat.negotiate.ToString() + ",";
            }
            if (rbtn_actualize.Checked)
            {
                contact.ContactStatus += ContactStat.actualize.ToString() + ",";
            }
            if (rbtn_traceservice.Checked)
            {
                contact.ContactStatus += ContactStat.traceservice.ToString() + ",";
            }
            if (rbtn_last.Checked)
            {
                contact.ContactStatus += ContactStat.last.ToString() + ",";
            }

            contact.ThisFee = float.Parse(tbx_thisfee.Text);
            if (cbx_travel.Checked)
            {
                contact.FeeUsed += ContactFeeUsed.travel.ToString() + ",";
            }
            if (cbx_food.Checked)
            {
                contact.FeeUsed += ContactFeeUsed.food.ToString() + ",";
            }
            if (cbx_gift.Checked)
            {
                contact.FeeUsed += ContactFeeUsed.gift.ToString() + ",";
            }
            if (cbx_out.Checked)
            {
                contact.FeeUsed += ContactFeeUsed.outer.ToString() + ",";
            }
            contact.ContactContent  = tbx_contactcontent.Text;
            contact.NextContactAim  = tbx_nextcontactaim.Text;
            contact.NextContactTime = DateTime.Parse(tbx_nextcontacttime.Text);
            #endregion

            //如果contactid==0则插入操作,否则修改
            if (contactid == 0)
            {
                contact.ContactTimes++;
                contact.ID             = cm.AddContact(contact);
                contactid              = contact.ID;
                ViewState["ContactID"] = contact.ID.ToString();
                Response.Write("<script>alert('添加成功!');close();opener.document.location.href=opener.document.location.href</script>");
            }
            else
            {
                cm.UpdateContact(contact);
                Response.Write("<script>alert('修改成功!');close();</script>");
            }

            //修改client信息

            client.BargainPrognosis = contact.BargainPrognosis;
            client.ContactTimes     = contact.ContactTimes;
            client.CurStatus        = contact.ContactStatus;
            client.SellPhase        = contact.ContactStatus;
            client.Fee            += contact.ThisFee;
            client.UpdateTime      = contact.UpdateTime;
            client.ContactTime     = contact.ContactTime;
            client.NextContactTime = DateTime.Parse(tbx_nextcontacttime.Text);
            if (client.FirstContactTime == DateTime.Parse("1900-1-1"))
            {
                client.FirstContactTime = contact.ContactTime;
            }
            cm.UpdateClient(client);
            DisplayClientInfo();

            //上传附件
            UploadAtt();

            ControlClientContactHistory1.MyClientID = clientid;
            ControlClientContactHistory1.BindData();
        }
Exemple #7
0
        private void BindData()
        {
            UDS.Components.CM         cm     = new UDS.Components.CM();
            UDS.Components.ClientInfo client = new UDS.Components.ClientInfo();
            SqlDataReader             dr     = null;

            clientid = ((Request.Params["clientid"] == null) || (Request.Params["clientid"].ToString().Trim() == ""))?0:Int32.Parse(Request.Params["clientid"]);
            if (clientid != 0)
            {
                dr     = cm.GetLinkmanFromClient(clientid);
                client = cm.GetClientAllInfo(clientid);
            }
            else             //如果没有传入clientid那么检查是否有临时linkman
            {
                string linkmanstring = (Session["tmplinkmanid"] == null)?"0":Session["tmplinkmanid"].ToString();
                if (linkmanstring.EndsWith(","))
                {
                    linkmanstring = linkmanstring.Substring(0, linkmanstring.Length - 1);
                }
                dr = cm.GetLinkmanByID(linkmanstring);
            }
//			rbl_LinkmanList.DataSource = dr;
//			rbl_LinkmanList.DataTextField = "Name";
//			rbl_LinkmanList.DataValueField = "id";
//			rbl_LinkmanList.DataBind();
            while (dr.Read())
            {
                ListItem li = new ListItem();
                if (Session["cm_permission"].ToString() == "administrator")
                {
                    li.Text = "<a href='Linkman.aspx?LinkmanID=" + dr["ID"].ToString() + "'>" + dr["Name"].ToString() + "</a>";
                }
                else
                {
                    li.Text = dr["Name"].ToString();
                }

                li.Value = dr["ID"].ToString();
                rbl_LinkmanList.Items.Add(li);
            }
            dr.Close();
            //如果临时主要联系人存在则让它处于选中状态
            if (Session["tmpchief"] != null)
            {
                //找到tmpchief的index值并让它处于选中状态
                foreach (ListItem lt in rbl_LinkmanList.Items)
                {
                    if (lt.Value == Session["tmpchief"].ToString())
                    {
                        lt.Selected = true;
                    }
                }
            }
            else
            {
                foreach (ListItem lt in rbl_LinkmanList.Items)
                {
                    if (lt.Value == client.ChiefLinkmanID.ToString())
                    {
                        lt.Selected = true;
                    }
                }
            }
        }