예제 #1
0
 protected void imgbtnSubmit_Click(object sender, ImageClickEventArgs e)
 {
     //如果传过来的typeid的值为空,则执行添加操作
     if (Request.QueryString["cpid"] == null)
     {
         if (Page.IsValid)
         {
             CustomerPriceTB cpt = new CustomerPriceTB();
             cpt.CusID  = Convert.ToInt32(ddlName.SelectedValue);
             cpt.Cid    = Convert.ToInt32(ddlCompany.SelectedValue);
             cpt.PNo    = ddlPno.Text;
             cpt.CpName = txtCpname.Text;
             cpt.Remark = txtRemark.Text;
             if (Page.IsValid)
             {
                 int cnt = cpm.InsertInfo(cpt);
                 if (cnt > 0)
                 {
                     //如果添加成功,则跳转到查询页面
                     Response.Redirect("~/PriceManager/CustomerPrice/SelectCustomerPrice.aspx");
                 }
                 else
                 {
                     lblMessage.Text = "添加失败!";
                 }
             }
         }
     }
     else
     {
         CustomerPriceTB cp     = new CustomerPriceTB();
         string          PNo    = ddlPno.Text;
         string          remark = txtRemark.Text;
         int             cpid   = Convert.ToInt32(Request.QueryString["cpid"]);
         if (Page.IsValid)
         {
             int cnt = cpm.UpdateTemp(cpid, PNo, remark);
             if (cnt > 0)
             {
                 //如果修改成功,则跳转到查询页面
                 Response.Redirect("~/PriceManager/CustomerPrice/SelectCustomerPrice.aspx");
             }
             else
             {
                 lblMessage.Text = "修改失败!";
             }
         }
     }
 }
예제 #2
0
        //插入数据
        public int InsertInfo(CustomerPriceTB cp)
        {
            string strsql = "insert into customerpricetb values(@cusid,@cid,@pno,@cpname,@remark)";

            SqlParameter[] paras = new SqlParameter[] {
                new SqlParameter("@cusid", cp.CusID),
                new SqlParameter("@cid", cp.Cid),
                new SqlParameter("@pno", cp.PNo),
                new SqlParameter("@cpname", cp.CpName),
                new SqlParameter("@remark", cp.Remark)
            };
            int cnt = DBHelper.ExecuteCommand(strsql, paras);

            return(cnt);
        }
예제 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //显示模板
            ddlPno.DataSource     = cpm.GetAllInfo();
            ddlPno.DataTextField  = "PNo";
            ddlPno.DataValueField = "PNo";
            ddlPno.DataBind();

            //如果传过来的值是空的,则是添加
            if (Request.QueryString["cpid"] == null)
            {
                //显示客户
                ddlName.DataSource     = cm.GetAllCustomers();
                ddlName.DataTextField  = "CusName";
                ddlName.DataValueField = "CusID";
                ddlName.DataBind();

                //显示公司
                ddlCompany.DataSource     = ccm.GetAllCarrieCompany();
                ddlCompany.DataTextField  = "CoName";
                ddlCompany.DataValueField = "Cid";
                ddlCompany.DataBind();
            }
            //不为空,则为修改
            else
            {
                //填充页面信息
                ddlName.Visible    = false;
                ddlCompany.Visible = false;
                lblCus.Visible     = true;
                lblCompany.Visible = true;
                int             cpid = Convert.ToInt32(Request.QueryString["cpid"]);
                CustomerPriceTB cp   = new CustomerPriceTB();
                cp = cpm.GetInfoById(cpid);

                ddlName.Visible    = false;
                ddlCompany.Visible = false;
                lblCus.Text        = cp.customer.CusName;
                lblCompany.Text    = cp.carriecomapny.CoName;
                ddlPno.Text        = cp.PNo;
                txtCpname.Text     = cp.CpName;
                txtRemark.Text     = cp.Remark;
            }
        }
    }
예제 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //填充数据
            allInfo             = pm.GetAllInfo();
            anpPage.RecordCount = allInfo.Count;
            DisPlay();

            if (Session["cp"] != null)
            {
                CustomerPriceTB cp = Session["cp"] as CustomerPriceTB;
                gvTemp.DataSource = pm.GetPriceBypno(cp.PNo);
                gvTemp.DataBind();
            }
        }
    }
예제 #5
0
    //计算运费
    private void Charging()
    {
        //根据客户id和公司id获得模板编号
        CustomerPriceTB cpt   = new CustomerPriceTB();
        int             cusid = Convert.ToInt32(ddlName.SelectedValue);
        int             cid   = Convert.ToInt32(ddlCompany.SelectedValue);

        cpt = cpm.GetInfoByCusidAndCid(cusid, cid);
        //根据模板编号,公斤数和目的地计算运费
        string  pno  = cpt.PNo;
        double  kilo = Convert.ToDouble(txtKilo.Text);
        string  des  = txtDes.Text;
        PriceTB pt   = new PriceTB();

        pt = pm.GetPriceByInfo(pno, kilo, des);
        //计算出价格
        txtPrice.Text = pt.Price.ToString();
    }
예제 #6
0
    //查看价格模板
    protected void lkbtnTemp_Click(object sender, EventArgs e)
    {
        int cusid = Convert.ToInt32(ddlName.SelectedValue);
        int cid   = Convert.ToInt32(ddlCompany.SelectedValue);
        int cnt   = cpm.GetCountInfo(cusid, cid);

        if (cnt <= 0)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('没有该客户在该公司的价格信息!')</script>");
        }
        else
        {
            CustomerPriceTB cp  = cpm.GetInfoByCusidAndCid(cusid, cid);
            int             res = pm.GetCount(cp.PNo);
            if (res <= 0)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('没有此价格模板!')</script>");
            }
            Session["cp"] = cp;
            Response.Redirect("~/PriceManager/CustomerPrice/Price.aspx");
        }
    }
예제 #7
0
        //根据sql语句查询
        private static List <CustomerPriceTB> GetCustomersBySql(string strsql)
        {
            CustomersService     cs  = new CustomersService();
            CarrieCompanyService ccs = new CarrieCompanyService();

            List <CustomerPriceTB> list = new List <CustomerPriceTB>();

            DataTable table = DBHelper.GetTable(strsql);

            foreach (DataRow row in table.Rows)
            {
                CustomerPriceTB cp = new CustomerPriceTB();
                cp.Cpid          = Convert.ToInt32(row["cpid"]);
                cp.carriecomapny = ccs.GetCompanyByid(Convert.ToInt32(row["cid"]));
                cp.customer      = cs.GetCusmoerByid(Convert.ToInt32(row["cusid"]));
                cp.CusID         = Convert.ToInt32(row["cusid"]);
                cp.Cid           = Convert.ToInt32(row["cid"]);
                cp.CpName        = row["cpname"].ToString();
                cp.PNo           = row["pno"].ToString();
                cp.Remark        = row["remark"].ToString();
                list.Add(cp);
            }
            return(list);
        }
예제 #8
0
    public static string LoadDataFromExcel1(string filePath, string fileName, string tableName)
    {
        CustomerPriceService priceservce = new CustomerPriceService();
        string Mess = string.Empty;

        try
        {
            if (!tableName.EndsWith("$"))
            {
                tableName = tableName + "$";
            }

            string          strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + fileName + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'";
            OleDbConnection OleConn = new OleDbConnection(strConn);
            OleConn.Open();
            string           sql        = "SELECT * FROM [" + tableName + "]";
            OleDbCommand     com        = new OleDbCommand(sql, OleConn);
            OleDbDataAdapter OleDaExcel = new OleDbDataAdapter(sql, OleConn);
            DataSet          ds         = new DataSet();
            OleDaExcel.Fill(ds, tableName);
            OleConn.Close();
            int k         = 0;
            int Datacount = 0;
            for (int n = 0; n < ds.Tables.Count; n++)
            {
                if (ds.Tables[n].Rows.Count < 1)
                {
                    Mess = "没有数据!";
                    Datacount++;
                }
            }
            for (int j = 0; j < ds.Tables.Count; j++)
            {
                for (int i = 0; i < ds.Tables[j].Rows.Count; i++)
                {
                    long   num    = Convert.ToInt64(ds.Tables[j].Rows[i + 1][1]);
                    string sqlStr = "insert into CustomerSentTB(Rid,CusID,Cid,Destination,Kilo,Price,Resdate,IsSet) values";
                    sqlStr += " (" + ds.Tables[j].Rows[i + 1][1].ToString() + ",";    //面单号
                    //面单分配
                    DisNoteManager numdis = new DisNoteManager();
                    DisNoteTB      dnt    = new DisNoteTB();
                    //根据面单号查客户ID和公司ID
                    dnt = numdis.GetNoteByRid(Convert.ToInt64(ds.Tables[j].Rows[i + 1][1]));
                    if (dnt.Customer != null)
                    {
                        sqlStr += dnt.Customer.CusID + ",";     //客户ID
                        sqlStr += dnt.CarrieCompany.Cid + ",'"; //公司ID
                    }
                    else
                    {
                        sqlStr += "null" + ",";
                        sqlStr += "null" + ",'";
                    }
                    sqlStr += ds.Tables[j].Rows[i + 1][2].ToString() + "',";    //目的地
                    double kg = Convert.ToDouble(ds.Tables[j].Rows[i + 1][3]);
                    if (kg % 1 > 0)
                    {
                        kg = kg - kg % 1 + 1;
                    }
                    sqlStr += Convert.ToDouble(ds.Tables[j].Rows[i + 1][3]) + ",";    //公斤数
                    if (dnt.Customer != null)
                    {
                        CustomerPriceTB tem = new CustomerPriceTB();
                        tem = priceservce.GetInfoByCusidAndCid(dnt.Customer.CusID, dnt.CarrieCompany.Cid);
                        PriceTB       pt = new PriceTB();
                        PricesManager pm = new PricesManager();
                        pt = pm.GetPriceByInfo(tem.PNo, kg, ds.Tables[j].Rows[i + 1][2].ToString());
                        double price = pt.Price;
                        sqlStr += price + ",'";    //运费
                    }
                    else
                    {
                        sqlStr += 0 + ",'";                                                             //运费
                    }
                    sqlStr += Convert.ToDateTime(ds.Tables[j].Rows[i + 1][4].ToString().Trim()) + "',"; //揽件时间
                    sqlStr += 0 + ")";
                    int row = DBHelper.ExecuteCommand(sqlStr);
                    k += row;
                }
            }
            Mess = k.ToString();
            return(Mess);
        }
        catch (Exception ex)
        {
            Mess = "" + ex.Message;
            return(Mess);
        }
    }
예제 #9
0
 //插入数据
 public int InsertInfo(CustomerPriceTB cp)
 {
     return(cps.InsertInfo(cp));
 }