protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Usermanager"] == null)
     {
         Response.Redirect("~/Login.aspx");
     }
     else
     {
         if (!IsPostBack)
         {
             //判断是否为编辑
             if (Request.QueryString["Cusid"] != null)
             {
                 //接受前页面传过来的Cusid值
                 int Cusid = Convert.ToInt32(Request.QueryString["Cusid"]);
                 //获取客户信息,传输到当前页面的文本框中
                 CustomersTB customer = cus.GetCusmoerByid(Cusid);
                 txtCusName.Text = customer.CusName.ToString();
                 txtTel.Text     = customer.CusTel.ToString();
                 if (customer.IsCounterman == "是")
                 {
                     rdoYes.Checked = true;
                 }
                 else
                 {
                     rdoNo.Checked = true;
                 }
                 txtRemark.Text = customer.Remark.ToString();
             }
         }
     }
 }
Ejemplo n.º 2
0
        //得到数据
        private static List <CustomersTB> GetCustomersBySql(string strsql)
        {
            List <CustomersTB> list = new List <CustomersTB>();

            DataTable table = DBHelper.GetTable(strsql);

            foreach (DataRow row in table.Rows)
            {
                CustomersTB cut = new CustomersTB();
                cut.CusID        = Convert.ToInt32(row["CusID"]);
                cut.CusName      = row["CusName"].ToString();
                cut.CusTel       = row["CusTel"].ToString();
                cut.IsCounterman = row["IsCounterman"].ToString();
                if (cut.IsCounterman == "True")
                {
                    cut.IsCounterman = "是";
                }
                else
                {
                    cut.IsCounterman = "否";
                }
                cut.Remark = row["Remark"].ToString();

                list.Add(cut);
            }
            return(list);
        }
Ejemplo n.º 3
0
    protected void ddlName_SelectedIndexChanged(object sender, EventArgs e)
    {
        int         cusid = Convert.ToInt32(ddlName.SelectedValue);
        CustomersTB cs    = new CustomersTB();

        cs = cm.GetCusmoerByid(cusid);
        //如果该员工不是业务员,则不能有价格模板
        if (cs.IsCounterman == "False")
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('该客户不是业务员!')</script>");
        }
    }
Ejemplo n.º 4
0
        //添加新客户
        public int InsertCustomer(CustomersTB cus)
        {
            string str = "insert into CustomersTB values (@CusName,@CusTel,@IsCounterman,@Remark)";

            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@CusName", cus.CusName),
                new SqlParameter("@CusTel", cus.CusTel),
                new SqlParameter("@IsCounterman", cus.IsCounterman),
                new SqlParameter("@Remark", cus.Remark)
            };
            return(DBHelper.ExecuteCommand(str, para));
        }
Ejemplo n.º 5
0
        //根据客户Id修改客户信息
        public int UpdateCustomerByCusId(int Cusid, CustomersTB cus)
        {
            string str = "Update CustomersTB set CusName=@CusName,CusTel=@CusTel,IsCounterman=@IsCounterman,Remark=@Remark where Cusid=@Cusid";

            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@Cusid", Cusid),
                new SqlParameter("@CusName", cus.CusName),
                new SqlParameter("@CusTel", cus.CusTel),
                new SqlParameter("@IsCounterman", cus.IsCounterman),
                new SqlParameter("@Remark", cus.Remark)
            };
            return(DBHelper.ExecuteCommand(str, para));
        }
    //获取当前文本框的值
    public CustomersTB GetText()
    {
        CustomersTB Cuss = new CustomersTB();

        Cuss.CusName = txtCusName.Text.Trim();
        Cuss.CusTel  = txtTel.Text.Trim();
        if (rdoYes.Checked == true)
        {
            Cuss.IsCounterman = "1";
        }
        else
        {
            Cuss.IsCounterman = "0";
        }
        Cuss.Remark = txtRemark.Text.Trim();
        return(Cuss);
    }
Ejemplo n.º 7
0
    protected void imgbtnsel_Click(object sender, ImageClickEventArgs e)
    {
        CustomerPianTB cp    = new CustomerPianTB();
        int            cusid = Convert.ToInt32(ddlcus.SelectedValue);
        DateTime       qtime = Convert.ToDateTime(txtstime.Text);
        DateTime       ttime = Convert.ToDateTime(txtttime.Text);

        try
        {
            if (customerpianmanager.GetCustomerPianTBById(cusid, qtime, ttime) != null)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('该用户信息已存在,请确认业务员及时间。')</script>");
                return;
            }
        }
        catch (Exception ex)
        {
            try
            {
                CustomersTB cus  = customersmanager.GetCusmoerByid(cusid);
                string      name = cus.CusName; //获取客户名

                DisNoteTB dis    = disnotemanager.GetDisNoteTBById(cusid, qtime, ttime);
                double    oddmon = dis.Sum;   //获取面单费用
                string    issrt  = dis.IsSet; //获取面单费用是否已结算
                if (issrt == "是")
                {
                    cp.Remark = "面单费已结!";
                }
                else
                {
                    cp.Remark = "面单费未结!";
                }

                CustomerSentTB cs      = customersentmanager.GetCustomerSentTBById(cusid, qtime, ttime);
                double         sendmon = cs.Price;//获取发件费

                CustomerSendTB cf      = customersendmanager.GetCustomerSendTBById(cusid, qtime, ttime);
                double         givemon = cf.EAllPrice;//获取送件费

                SentTB st      = sentmanager.GetSentTBById(cusid, qtime, ttime);
                double backmon = st.Price;//获取收到付件返利

                AcceptTB at     = acceptmanager.GetAcceptTBById(cusid, qtime, ttime);
                double   accmon = at.Price;//获取派收到付件款

                IAEManagerTB ia       = iaemanagermanager.GetIAEManagerTBById(cusid, qtime, ttime);
                double       othermon = ia.Price;                                         //获取其他费用

                double allmon = oddmon + sendmon + backmon - givemon - accmon + othermon; //总计

                string ISsettle = "false";

                cp.CusID    = Convert.ToInt32(cusid);
                cp.DateMon  = ttime;
                cp.OddMon   = oddmon;
                cp.SendMon  = sendmon;
                cp.GiveMon  = givemon;
                cp.BackMon  = backmon;
                cp.AccMon   = accmon;
                cp.OtherMon = othermon;
                cp.AllMon   = allmon;
                cp.ISsettle = ISsettle;

                int cou = customerpianmanager.AddCustomerPianTBInfo(cp);
                if (cou == 1)
                {
                    allInfo             = customerpianmanager.GetAllCustomerPianTBInfo(cusid);
                    anpInfo.RecordCount = allInfo.Count();
                    BindData();
                    anpInfo.CurrentPageIndex = 1;
                }
            }
            catch (Exception)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('无该用户信息,请确认业务员及时间。')</script>");
                return;
            }
        }
    }
Ejemplo n.º 8
0
    public static void ExportExcel <T>(List <T> objList, string FileName, Dictionary <string, string> columnInfo)
    {
        if (columnInfo.Count == 0)
        {
            return;
        }
        if (objList.Count == 0)
        {
            return;
        }
        //生成EXCEL的HTML
        string excelStr = "";

        Type myType = objList[0].GetType();
        //根据反射从传递进来的属性名信息得到要显示的属性
        //根据反射从传递进来的属性名信息得到要显示的属性
        List <PropertyInfo> myPro = new List <PropertyInfo>();

        foreach (string cName in columnInfo.Keys)
        {
            PropertyInfo p = myType.GetProperty(cName);
            if (p != null)
            {
                myPro.Add(p);
                excelStr += columnInfo[cName] + "\t";
            }
        }
        //如果没有找到可用的属性则结束
        if (myPro.Count == 0)
        {
            return;
        }
        excelStr += "\n";

        foreach (T obj in objList)
        {
            foreach (PropertyInfo p in myPro)
            {
                string str = "";

                Object objec = p.GetValue(obj, null);
                if (objec != null)
                {
                    //判断objec是否是外键对象类型,如果不是,直接返回
                    if (Type.GetTypeCode(objec.GetType()) == TypeCode.String || Type.GetTypeCode(objec.GetType()) == TypeCode.Int64 || Type.GetTypeCode(objec.GetType()) == TypeCode.Int32 || Type.GetTypeCode(objec.GetType()) == TypeCode.Double || Type.GetTypeCode(objec.GetType()) == TypeCode.DBNull)
                    {
                        str = objec.ToString().Trim();
                    }
                    else if (Type.GetTypeCode(objec.GetType()) == TypeCode.DateTime)
                    {
                        str = Convert.ToDateTime(objec).ToString("yyyy-M-d");
                    }

                    else
                    {
                        CustomersTB Customers = objec as CustomersTB;
                        if (Customers != null)
                        {
                            str = GetObjectPropertyValue(Customers);
                        }
                        else
                        {
                            CarrieCompanyTB carriecompany = objec as CarrieCompanyTB;
                            if (carriecompany != null)
                            {
                                str = GetObjectPropertyValue(carriecompany);
                            }
                        }
                    }

                    if ((p.Name == "CusTel" || p.Name == "Telephone" || p.Name == "LinkmanTel" || p.Name == "BeginNo" || p.Name == "Rid" || p.Name == "CSid" || p.Name == "EndNo") && str != "")
                    {
                        excelStr += "'" + str + "\t";
                    }
                    else
                    {
                        excelStr += str + "\t";
                    }
                }
                else
                {
                    excelStr += "\t";
                }
            }
            excelStr += "\n";
        }
        //输出Excel
        HttpResponse rs = System.Web.HttpContext.Current.Response;

        rs.Clear();
        rs.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
        rs.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8));
        rs.ContentType = "application/ms-excel";
        rs.Write(excelStr);
        rs.End();
    }
Ejemplo n.º 9
0
 //根据Cusid修改客户信息
 public int UpdateCustomerByCusId(int Cusid, CustomersTB cus)
 {
     return(customerservice.UpdateCustomerByCusId(Cusid, cus));
 }
Ejemplo n.º 10
0
 //插入新的客户
 public int InsertCustomer(CustomersTB cus)
 {
     return(customerservice.InsertCustomer(cus));
 }