protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //绑定数据 ddlName.DataSource = cm.GetAllCustomers(); ddlName.DataTextField = "cusname"; ddlName.DataValueField = "cusid"; ddlName.DataBind(); ddlCompany.DataSource = ccm.GetAllCarrieCompany(); ddlCompany.DataTextField = "coname"; ddlCompany.DataValueField = "cid"; ddlCompany.DataBind(); //如果传过来的值不为空,则为添加操作 if (Request.QueryString["csid"] != null) { CustomerSentTB cst = new CustomerSentTB(); //跟据传过来的id获取信息 cst = csm.GetInfoByid(Convert.ToInt32(Request.QueryString["csid"])); //如果为无头件,则不显示客户姓名和公司姓名 if (cst.cusid == 0) { ddlName.Visible = false; ddlCompany.Visible = false; } else { ddlName.SelectedValue = cst.cusid.ToString(); ddlCompany.SelectedValue = cst.Cid.ToString(); } //填充页面信息 txtRid.Text = cst.Rid.ToString(); txtDes.Text = cst.Destination; txtKilo.Text = cst.Kilo.ToString(); txtPrice.Text = cst.Price.ToString(); txtRemark.Text = cst.Remark; if (cst.IsSet == "是") { rdoYes.Checked = true; } else { rdoNo.Checked = true; } } } }
//修改信息 public int UpdateInfo(CustomerSentTB cst) { string strsql = "update customersenttb set rid=@Rid,destination=@des,kilo=@kilo,price=@price,resdate=@Resdate,isset=@IsSet,remark=@remark where rid=@rid"; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@rid", cst.Rid), new SqlParameter("@cusid", cst.cusid), new SqlParameter("@cid", cst.Cid), new SqlParameter("@des", cst.Destination), new SqlParameter("@kilo", cst.Kilo), new SqlParameter("@price", cst.Price), new SqlParameter("@Resdate", cst.Resdate), new SqlParameter("@IsSet", cst.IsSet), new SqlParameter("@remark", cst.Remark), }; return(DBHelper.ExecuteCommand(strsql, paras)); }
//插入信息 public int InsertInfo(CustomerSentTB cst) { string strsql = "insert into customersenttb values(@Rid,@cusid,@cid,@des,@kilo,@price,@Resdate,@IsSet,@remark)"; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@rid", cst.Rid), new SqlParameter("@cusid", cst.cusid), new SqlParameter("@cid", cst.Cid), new SqlParameter("@des", cst.Destination), new SqlParameter("@kilo", cst.Kilo), new SqlParameter("@price", cst.Price), new SqlParameter("@Resdate", cst.Resdate), new SqlParameter("@IsSet", cst.IsSet), new SqlParameter("@remark", cst.Remark), }; return(DBHelper.ExecuteCommand(strsql, paras)); }
//根据sql语句得到信息 public static List <CustomerSentTB> GetAllBySql(string strsql) { CustomersService cst = new CustomersService(); CarrieCompanyService ccs = new CarrieCompanyService(); List <CustomerSentTB> all = new List <CustomerSentTB>(); DataTable ds = DBHelper.GetTable(strsql); foreach (DataRow row in ds.Rows) { CustomerSentTB cs = new CustomerSentTB(); cs.CSid = Convert.ToInt32(row["csid"]); cs.Rid = (long)row["rid"]; //cs.cusid = Convert.ToInt32(row["cusid"]); cs.cusid = row["cusid"] != DBNull.Value ? Convert.ToInt32(row["cusid"]) : 0; //cs.Cid = Convert.ToInt32(row["cid"]); cs.Cid = row["cid"] != DBNull.Value ? Convert.ToInt32(row["cid"]) : 0; if (cs.cusid != 0) { cs.customer = cst.GetCusmoerByid(Convert.ToInt32(row["cusid"])); cs.carriecompany = ccs.GetCompanyByid(Convert.ToInt32(row["cid"])); } cs.Destination = row["destination"].ToString(); cs.Kilo = Convert.ToDouble(row["kilo"]); cs.Price = Convert.ToDouble(row["price"]); cs.Resdate = Convert.ToDateTime(row["resdate"]); cs.IsSet = (row["isset"].ToString()); if (cs.IsSet == "true") { cs.IsSet = "是"; } else { cs.IsSet = "否"; } cs.Remark = row["remark"].ToString(); all.Add(cs); } return(all); }
private static List <CustomerSentTB> GetCustomerSentTBBySql(string strsql) { List <CustomerSentTB> list = new List <CustomerSentTB>(); DataTable table = DBHelper.GetTable(strsql); foreach (DataRow row in table.Rows) { CustomerSentTB cs = new CustomerSentTB(); cs.CSid = Convert.ToInt32(row["csid"]); cs.Rid = Convert.ToInt32(row["rid"]); cs.cusid = Convert.ToInt32(row["cusid"]); cs.Cid = Convert.ToInt32(row["cid"]); cs.Destination = row["destination"].ToString(); cs.Kilo = (float)(row["kilo"]); cs.Price = Convert.ToDouble(row["price"]); cs.Resdate = Convert.ToDateTime(row["resdate"]); cs.Remark = row["remark"].ToString(); list.Add(cs); } return(list); }
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; } } }
//修改信息 public int UpdateInfo(CustomerSentTB cst) { return(css.UpdateInfo(cst)); }
//插入信息 public int InsertInfo(CustomerSentTB cst) { return(css.InsertInfo(cst)); }
protected void imgbtnSubmit_Click(object sender, ImageClickEventArgs e) { //如果传过来的值为空则为添加 if (Request.QueryString["csid"] == null) { CustomerSentTB cst = new CustomerSentTB(); cst.Rid = Convert.ToInt64(txtRid.Text); cst.cusid = Convert.ToInt32(ddlName.SelectedValue); cst.Cid = Convert.ToInt32(ddlCompany.SelectedValue); cst.Destination = txtDes.Text; cst.Kilo = Convert.ToDouble(txtKilo.Text); cst.Price = Convert.ToDouble(txtPrice.Text); cst.Resdate = Convert.ToDateTime(txtDatetime.Text); cst.Remark = txtRemark.Text; if (Page.IsValid) { if (rdoYes.Checked == true) { cst.IsSet = "1"; } else { cst.IsSet = "0"; } int cnt = csm.InsertInfo(cst); if (cnt > 0) { //添加成功,跳转到查询页面 Response.Redirect("~/PriceManager/CarriageMoney/CustomerSent.aspx"); } else { lblMessage.Text = "添加失败!"; } } } //如果不为空则为修改 else { CustomerSentTB cst = new CustomerSentTB(); cst.Rid = Convert.ToInt64(txtRid.Text); cst.cusid = Convert.ToInt32(ddlName.SelectedValue); cst.Cid = Convert.ToInt32(ddlCompany.SelectedValue); cst.Destination = txtDes.Text; cst.Kilo = Convert.ToDouble(txtKilo.Text); cst.Price = Convert.ToDouble(txtPrice.Text); cst.Resdate = Convert.ToDateTime(txtDatetime.Text); cst.Remark = txtRemark.Text; if (rdoYes.Checked == true) { cst.IsSet = "1"; } else { cst.IsSet = "0"; } if (Page.IsValid) { int cnt = csm.UpdateInfo(cst); if (cnt > 0) { //修改成功,跳转到查询页面 Response.Redirect("~/PriceManager/CarriageMoney/CustomerSent.aspx"); } else { lblMessage.Text = "修改失败!"; } } } }