protected void Page_Load(object sender, EventArgs e) { if (Session["Usermanager"] == null) { Response.Redirect("~/Login.aspx"); } else { if (!IsPostBack) { if (Request.QueryString["sid"] != null) { //显示信息 int sid = Convert.ToInt32(Request.QueryString["sid"]); SentTB st = new SentTB(); st = sm.GetSentTBById(sid); txtNumbers.Text = st.CSid.ToString(); lblCom.Text = st.Cid.ToString(); lblCus.Text = st.CusID.ToString(); txtMoney.Text = st.Price.ToString(); txtDatetime.Text = st.BeginDate.ToString(); txtWeight.Text = st.Kilo.ToString(); txtRemark.Text = st.Remark; } } } }
//遍历数组,拿出数据 private static List <SentTB> GetSentTBBySql(string strsql) { CustomersService cs = new CustomersService(); CarrieCompanyService ccs = new CarrieCompanyService(); List <SentTB> list = new List <SentTB>(); DataTable table = DBHelper.GetTable(strsql); foreach (DataRow row in table.Rows) { SentTB st = new SentTB(); st.Sid = Convert.ToInt32(row["sid"]); st.CusID = Convert.ToInt32(row["cusid"]); st.Cid = Convert.ToInt32(row["cid"]); st.CSid = Convert.ToInt64(row["csid"]); st.Kilo = Convert.ToDouble(row["kilo"]); st.Price = Convert.ToDouble(row["price"]); st.BeginDate = Convert.ToDateTime(row["begindate"]); st.Remark = row["remark"].ToString(); st.cust = cs.GetCusmoerByid(Convert.ToInt32(row["cusid"])); st.company = ccs.GetCompanyByid(Convert.ToInt32(row["cid"])); list.Add(st); } return(list); }
protected void ImgbtnAdd_Click(object sender, ImageClickEventArgs e) { if (Page.IsValid) { if (Request.QueryString["sid"] == null) { //获取客户、公司 DisNoteTB nt = new DisNoteTB(); nt = dm.GetDisNoteTBByIds(txtNumbers.Text.ToString()); lblCus.Text = nt.Customer.CusName.ToString(); lblCom.Text = nt.CarrieCompany.CoName.ToString(); //插入数据 SentTB st = new SentTB(); st.CusID = nt.CusID; st.CSid = Convert.ToInt64(txtNumbers.Text); st.Cid = nt.Cid; st.Kilo = Convert.ToDouble(txtWeight.Text); st.Price = Convert.ToDouble(txtMoney.Text); st.BeginDate = Convert.ToDateTime(txtDatetime.Text); st.Remark = txtRemark.Text.ToString(); int count = sm.InsertSentTB(st); if (count > 0) { lblMessage.Text = "插入成功!<br>客户:" + lblCus.Text + "<br>承运公司:" + lblCom.Text + "<br>面单号:" + txtNumbers.Text + "<br>重量:" + txtWeight.Text + "<br>金额:" + txtMoney.Text + "<br>起运时间:" + txtDatetime.Text + "<br>备注:" + txtRemark.Text; } else { lblMessage.Text = "添加失败!"; } } else { //修改信息 SentTB st = new SentTB(); st.Sid = Convert.ToInt32(Request.QueryString["sid"]); st.CusID = Convert.ToInt32(lblCus.Text); st.Cid = Convert.ToInt32(lblCom.Text); st.CSid = Convert.ToInt64(txtNumbers.Text); st.Kilo = Convert.ToDouble(txtWeight.Text); st.Price = Convert.ToDouble(txtMoney.Text); st.BeginDate = Convert.ToDateTime(txtDatetime.Text); st.Remark = txtRemark.Text; int count = sm.UpdateSentTB(st); if (count > 0) { Response.Redirect("~/AcceptandSent/SentShow.aspx"); } else { lblMessage.Text = "修改失败!"; } } } }
//添加揽发到付件 public int InsertSentTB(SentTB st) { string strsql = "insert into SentTB(CusID,Cid,CSid,Kilo,Price,BeginDate,Remark) values(@CusID,@Cid,@CSid,@Kilo,@Price,@BeginDate,@Remark)"; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@CusID", st.CusID), new SqlParameter("@Cid", st.Cid), new SqlParameter("@CSid", st.CSid), new SqlParameter("@Kilo", st.Kilo), new SqlParameter("@Price", st.Price), new SqlParameter("@BeginDate", st.BeginDate), new SqlParameter("@Remark", st.Remark) }; return(DBHelper.ExecuteCommand(strsql, paras)); }
//谷恒远1.11 //修改信息 public int UpdateSentTB(SentTB st) { string strsql = "update SentTB set CusID=@CusID,Cid=@Cid,CSid=@CSid,Kilo=@Kilo,Price=@Price,BeginDate=@BeginDate,Remark=@Remark where Sid=@Sid"; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@Sid", st.Sid), new SqlParameter("@CusID", st.CusID), new SqlParameter("@Cid", st.Cid), new SqlParameter("@Kilo", st.Kilo), new SqlParameter("@Price", st.Price), new SqlParameter("@CSid", st.CSid), new SqlParameter("@BeginDate", st.BeginDate), new SqlParameter("@Remark", st.Remark) }; return(DBHelper.ExecuteCommand(strsql, paras)); }
private static List <SentTB> GetSentTBSql(string strsql) { List <SentTB> list = new List <SentTB>(); DataTable table = DBHelper.GetTable(strsql); foreach (DataRow row in table.Rows) { SentTB st = new SentTB(); st.Sid = Convert.ToInt32(row["sid"]); st.CusID = Convert.ToInt32(row["cusid"]); st.Cid = Convert.ToInt32(row["cid"]); st.CSid = Convert.ToInt32(row["csid"]); st.Kilo = (float)row["kilo"]; st.Price = Convert.ToDouble(row["price"]); st.BeginDate = Convert.ToDateTime(row["begindate"]); st.Remark = row["remark"].ToString(); list.Add(st); } 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 UpdateSentTB(SentTB st) { return(ss.UpdateSentTB(st)); }
//插入信息 public int InsertSentTB(SentTB st) { return(ss.InsertSentTB(st)); }