protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string sYear = DateTime.Now.Year.ToString(); string sMonth = DateTime.Now.Month.ToString(); string sDay = DateTime.Now.Day.ToString(); if (sMonth.Length == 1) { sMonth = "0" + sMonth; } if (sDay.Length == 1) { sDay = "0" + sDay; } string sTemp = sYear + "-" + sMonth + "-" + sDay; this.TextBox1.Text = sTemp; this.TextBox2.Text = sTemp; DateTime Begin = Convert.ToDateTime("2000/1/1"); DateTime End = Convert.ToDateTime(TextBox2.Text).AddDays(1); DataSet ds = new BLL.Sale().GetList(AspNetPager2.PageSize, 1, " SaleDate between '" + Begin + "' and '" + End + "'"); AspNetPager2.RecordCount = 1; this.GridView1.DataSource = ds; this.GridView1.DataBind(); } }
public string GetTradeNo() //生成交易号码 { string sYear = DateTime.Now.Year.ToString(); //取年份 string sMonth = DateTime.Now.Month.ToString(); //取月份 string sDay = DateTime.Now.Day.ToString(); //取日期 if (sMonth.Length == 1) { sMonth = "0" + sMonth; } //小于10的月份变双位 if (sDay.Length == 1) { sDay = "0" + sDay; } //小于10 的日期变双位 string sTemp = sYear + sMonth + sDay + "001"; //生成当天初始的交易号 //string TradeNoSQL = "SELECT TradeNo FROM sales order by TradeNo DESC";//查询数据库中最大的交易号的SQL语句 //MySqlConnection TradeNoconn = new MySqlConnection(connStr);//连接数据库 //TradeNoconn.Open();//打开数据库 //MySqlCommand TradeNocmd = new MySqlCommand(TradeNoSQL, TradeNoconn);//执行查询 //MySqlDataReader reader = TradeNocmd.ExecuteReader();//读取数据 Model.Sale ml_sale = new BLL.Sale().GetModel(new BLL.Sale().GetMaxId() - 1); string MaxCode = ml_sale.TradeNo; if (MaxCode.Substring(1, 8) == sTemp.Substring(1, 8))//如果取得数据并且sTemp的前八位等于数据库中取得的数据的前八位 { long dd = Convert.ToInt64(sTemp); long cc = Convert.ToInt64(MaxCode); dd = cc + 1;//sTemp等于取得的交易号+1,否则sTemp等于初始生成的号码 sTemp = dd.ToString(); } return(sTemp);//返回sTemp }
public void LoadReport(BLL.Sale data) { try { List <BLL.Sale> POList = new List <BLL.Sale>(); List <BLL.SalesDetail> PODList = new List <BLL.SalesDetail>(); List <BLL.CompanyDetail> CList = new List <BLL.CompanyDetail>(); POList.Add(data); PODList.AddRange(data.SDetails); CList.Add(BLL.UserAccount.Company); rptQuickSales.Reset(); ReportDataSource data1 = new ReportDataSource("Sale", POList); ReportDataSource data2 = new ReportDataSource("SalesDetail", PODList); ReportDataSource data3 = new ReportDataSource("CompanyDetail", CList); rptQuickSales.LocalReport.DataSources.Add(data1); rptQuickSales.LocalReport.DataSources.Add(data2); rptQuickSales.LocalReport.DataSources.Add(data3); rptQuickSales.LocalReport.ReportPath = @"rpt\Transaction\rptQuickSales.rdlc"; rptQuickSales.RefreshReport(); } catch (Exception ex) { } }
protected void Button2_Click(object sender, EventArgs e) { DataSet ds = new BLL.Sale().GetList(AspNetPager2.PageSize, 1, " TradeNo LIKE '%" + this.TextBox3.Text + "%'"); AspNetPager2.RecordCount = Convert.ToInt32(ds.Tables[1].Rows[0]["Total"]); this.GridView1.DataSource = ds; this.GridView1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { DateTime Begin = Convert.ToDateTime(TextBox1.Text); DateTime End = Convert.ToDateTime(TextBox2.Text).AddDays(1); DataSet ds = new BLL.Sale().GetList(AspNetPager2.PageSize, 1, " SaleDate between '" + Begin + "' and '" + End + "'"); AspNetPager2.RecordCount = Convert.ToInt32(ds.Tables[1].Rows[0]["Total"]); this.GridView1.DataSource = ds; this.GridView1.DataBind(); }
protected void AspNetPager2_PageChanged(object sender, EventArgs e) { DateTime Begin = Convert.ToDateTime(TextBox1.Text); DateTime End = Convert.ToDateTime(TextBox2.Text).AddDays(1); //DataSet ds = new BLL.Sale().GetList(AspNetPager2.PageSize, AspNetPager2.CurrentPageIndex, " SaleDate between '" + Begin + "' and '" + End + "'"); DataSet ds = new BLL.Sale().GetList(AspNetPager2.PageSize, AspNetPager2.CurrentPageIndex, " TradeNo LIKE '%" + this.TextBox3.Text + "%'"); AspNetPager2.RecordCount = Convert.ToInt32(ds.Tables[1].Rows[0]["Total"]); this.GridView1.DataSource = ds; this.GridView1.DataBind(); }
public bool PORefNo_Filter(object obj) { try { BLL.Sale SO = obj as BLL.Sale; BLL.Customer S = cmbCustomer.SelectedItem as BLL.Customer; return(SO.CustomerId == S.Id); } catch (Exception ex) { } return(false); }
private void cmbSORefNo_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { BLL.Sale SO = cmbSORefNo.SelectedItem as BLL.Sale; SO.SearchText = SO.RefNo; if (SO.Find()) { foreach (var sod in SO.SDetails) { data.SDetail.SODId = sod.Id; data.SDetail.ProductId = sod.ProductId.Value; data.SDetail.Quantity = sod.Quantity.Value; data.SDetail.UnitPrice = sod.UnitPrice; data.SaveDetail(); } } } catch (Exception EX) { } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Params["Sale_ID"] != null && Request.Params["Sale_ID"].Trim() != "") { Model.Sale ml_sa = new BLL.Sale().GetModel(Convert.ToInt32(Request.Params["Sale_ID"])); this.Label10.Text = ml_sa.SaleDate.ToString("yyyy-M-d H:mm:ss"); this.Label11.Text = ml_sa.TradeNo.ToString(); Model.StoreHouse ml_sh = new BLL.StoreHouse().GetModel(Convert.ToInt32(ml_sa.StoreHouse_ID)); this.Label12.Text = ml_sh.Address; this.Label13.Text = "100"; this.Label14.Text = ml_sa.GatheringWay; this.Label15.Text = ml_sa.Account; this.Label16.Text = ""; this.Label17.Text = ml_sa.Address; Model.Customer ml_cu = new BLL.Customer().GetModel(Convert.ToInt32(ml_sa.Customer)); this.Label18.Text = ml_cu.Name; this.Label19.Text = new BLL.Employee().GetModel(ml_sa.Employee_ID).Name; //Label1.Text = Request.Params["Sale_ID"].Trim(); DataSet ds = new BLL.Sale_Detail().GetDetailAll(Convert.ToInt32(Request.Params["Sale_ID"])); Repeater1.DataSource = ds; Repeater1.DataBind(); } decimal TotalPrice = 0; foreach (RepeaterItem item in Repeater1.Items) { Label LB1 = (Label)item.FindControl("Label5"); //单价 Label LB2 = (Label)item.FindControl("Label4"); //数量 Label LB3 = (Label)item.FindControl("Label6"); //合计 LB3.Text = Math.Round((Convert.ToDecimal(LB1.Text) * Convert.ToDecimal(LB2.Text)), 3).ToString(); TotalPrice += Convert.ToDecimal(LB3.Text); } this.TotalPrice.Text = Math.Round((Convert.ToDecimal(TotalPrice)), 3).ToString(); Label9.Text = Maticsoft.Common.Rmb.CmycurD(TotalPrice); }
protected void Button2_Click(object sender, EventArgs e) { if (HiddenField1.Value == "") { Maticsoft.Common.MessageBox.Show(this, "请添加商品"); return; } else { Model.Sale ml_sale = new ZhangWei.Model.Sale(); ml_sale.SaleDate = Convert.ToDateTime(TextBox1.Text); ml_sale.Dept_ID = Convert.ToInt32(DropDownList1.SelectedValue); ml_sale.Customer = Convert.ToInt32(DropDownList5.SelectedValue);//客户 ml_sale.Employee_ID = Convert.ToInt32(DropDownList2.SelectedValue); ml_sale.Account = DropDownList4.SelectedValue; ml_sale.Address = TextBox2.Text; ml_sale.GatheringWay = DropDownList6.SelectedValue; ml_sale.StoreHouse_ID = Convert.ToInt32(DropDownList3.SelectedValue); ml_sale.TradeNo = GetTradeNo(); Int32 sale_id = new BLL.Sale().Add(ml_sale); string Ids = HiddenField1.Value.Replace(" ", "").Replace("\r\n", ""); string Qtys = HiddenField2.Value.Replace(" ", "").Replace("\r\n", ""); string Prices = HiddenField3.Value.Replace(" ", "").Replace("\r\n", ""); string[] ArrIds = Ids.Split(new char[] { '|' }); string[] ArrQty = Qtys.Split(new char[] { '|' }); string[] ArrPri = Prices.Split(new char[] { '|' }); for (int i = 0; i < ArrIds.Length - 1; i++) { Model.Sale_Detail ml_sa = new ZhangWei.Model.Sale_Detail(); BLL.Sale_Detail bl_sd = new ZhangWei.BLL.Sale_Detail(); ml_sa.Sale_ID = sale_id; ml_sa.Product_ID = Convert.ToInt32(ArrIds[i]); //ml_sa.SaleOrder_ID = 0; ml_sa.Quantity = Convert.ToDecimal(ArrQty[i]); ml_sa.Price = Convert.ToDecimal(ArrPri[i]); Model.StockPile ml_sp = new BLL.StockPile().GetModelByProId(Convert.ToInt32(ArrIds[i]), Convert.ToInt32(DropDownList3.SelectedValue)); BLL.StockPile bl_sp = new ZhangWei.BLL.StockPile(); if (ml_sp == null) { Model.Product ml_pr = new BLL.Product().GetModel(Convert.ToInt32(ArrIds[i])); ml_sp = new ZhangWei.Model.StockPile(); ml_sp.Product_ID = Convert.ToInt32(ArrIds[i]); ml_sp.Dept_ID = Convert.ToInt32(DropDownList1.SelectedValue); ml_sp.FirstEnterDate = DateTime.Now; ml_sp.LastLeaveDate = DateTime.Now; ml_sp.Price = Convert.ToDecimal(ArrPri[i]); ml_sp.Quantity = 0; ml_sp.StoreHouse_ID = Convert.ToInt32(DropDownList3.SelectedValue); ml_sp.Quantity -= Convert.ToDecimal(ArrQty[i]); bl_sp.Add(ml_sp); } else { ml_sp.Quantity -= Convert.ToDecimal(ArrQty[i]); ml_sp.LastLeaveDate = DateTime.Now; bl_sp.Update(ml_sp); } bl_sd.Add(ml_sa); } Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功,单号为:" + ml_sale.TradeNo, "/Sales/SaleReport.aspx"); } }