/// <summary> /// 初始化右侧商品细项按钮 /// </summary> private void initItemInfo() { PosBll pb = new PosBll(); //dtItemInfo = pb.GetItemPage(0, _iSum, true); _iStarIndex = dtItemInfo.Rows.Count; SetItemInfo(dtItemInfo); }
private void btnUpPage_Click(object sender, EventArgs e) { if (_iStarIndex > 0) { PosBll pb = new PosBll(); this.flpRight.Controls.Clear(); _iStarIndex = _iStarIndex - _iSum; //dtItemInfo = pb.GetItemPage(_iStarIndex, _iSum, true); SetItemInfo(dtItemInfo); } }
private void btnDownPage_Click(object sender, EventArgs e) { PosBll pb = new PosBll(); this.flpRight.Controls.Clear(); //清空控件 //dtItemInfo = pb.GetItemPage(_iStarIndex, _iSum, true);//查询全部指定数据 //DataTable dtTemp = pb.GetItemPage(0, _iRowCount, false);//查询全部数据 //if (_iStarIndex < dtTemp.Rows.Count) //{ // SetItemInfo(dtItemInfo); // _iStarIndex = _iStarIndex + _iSum; //} //else //{ // SetItemInfo(dtItemInfo); //} }
/// <summary> /// 添加购买商品事件 /// </summary> /// <param name="item_no"></param> private void addSaleItem(string item_no) { //初始化选择商品列表 PosBll pb = new PosBll(); //DataTable dtItemDetails = pb.GetItemDetails(item_no);//查询全部指定数据 DataTable dtItemDetails = null;//pb.GetItemDetails(item_no);//查询全部指定数据 //初始化选择商品列表 DataColumn dc = null; if (!_bColumnsHeader) { dc = dtSaleFlow.Columns.Add("NO", Type.GetType("System.Int32")); dc.AutoIncrement = true; //自动增加 dc.AutoIncrementSeed = 1; //起始为1 dc.AutoIncrementStep = 1; //步长为1 dc.AllowDBNull = false; // dc = dtSaleFlow.Columns.Add("Product", Type.GetType("System.String")); dc = dtSaleFlow.Columns.Add("Count", Type.GetType("System.String")); dc = dtSaleFlow.Columns.Add("FixedPrice", Type.GetType("System.Decimal")); dc = dtSaleFlow.Columns.Add("UnitPrice", Type.GetType("System.Decimal")); dc = dtSaleFlow.Columns.Add("Calculate", Type.GetType("System.Decimal")); this._bColumnsHeader = true; } DataRow newRow; newRow = dtSaleFlow.NewRow(); newRow["Product"] = dtItemDetails.Rows[0]["item_no"] + " \r\n" + dtItemDetails.Rows[0]["item_subname"]; newRow["Count"] = 1; newRow["FixedPrice"] = Gfunc.strToDecimal(dtItemDetails.Rows[0]["sale_price"].ToString()); newRow["UnitPrice"] = Gfunc.strToDecimal(dtItemDetails.Rows[0]["sale_price1"].ToString()); newRow["Calculate"] = Gfunc.strToDecimal(dtItemDetails.Rows[0]["sale_price1"].ToString()); #region //bool ifAdd = true; //if (this.dtSaleFlow.Rows.Count > 0) //{ // for (int i = 0; i < this.dtSaleFlow.Rows.Count; i++) // { // string strProduct = this.dtSaleFlow.Rows[i]["Product"].ToString(); // string strId = strProduct.Substring(0, strProduct.IndexOf("\r\n")); // //同一商品只需修改价格和数量。 // if (item_no.Equals(strId.Trim())) // { // decimal count = System.Decimal.Parse(this.dtSaleFlow.Rows[i]["Count"].ToString()) + 1; // decimal calculate = count * System.Decimal.Parse(dtItemDetails.Rows[0]["sale_price"].ToString()); // dtSaleFlow.Rows[i]["Product"] = dtItemDetails.Rows[0]["item_no"] + " \r\n" + dtItemDetails.Rows[0]["item_subname"]; // dtSaleFlow.Rows[i]["Count"] = count; // dtSaleFlow.Rows[i]["FixedPrice"] = UtilityClass.strToDecimal(dtItemDetails.Rows[0]["sale_price"].ToString()).ToString(); // dtSaleFlow.Rows[i]["UnitPrice"] = UtilityClass.strToDecimal(dtItemDetails.Rows[0]["sale_price1"].ToString()).ToString(); // dtSaleFlow.Rows[i]["Calculate"] = UtilityClass.strToDecimal(calculate.ToString()); // ifAdd = false; // } // //int sum = UtilityClass.strToDecimal(dtSaleFlow.Rows[i]["Calculate"]); // //this.lbTotal.Text = UtilityClass.strToDecimal(dtItemDetails.Rows[i]["Calculate"].ToString()).ToString(); // } // this.dgvSaleFlow.Refresh(); //} //if (ifAdd) //{ //合计 //} #endregion dtSaleFlow.Rows.Add(newRow); //合计总数 decimal decTotal = 0; decimal decCount = 0; for (int i = 0; i < dtSaleFlow.Rows.Count; i++) { decTotal = Gfunc.strToDecimal(dtSaleFlow.Rows[i]["Calculate"].ToString()) + decTotal; decCount = Gfunc.strToDecimal(dtSaleFlow.Rows[i]["Count"].ToString()) + decCount; } this.lbTotal.Text = decTotal.ToString(); this.lbCount.Text = decCount.ToString(); this.bindingSaleFlow.DataSource = dtSaleFlow; for (int i = 1; i <= dgvSaleFlow.RowCount; i++) { dgvSaleFlow.Rows[i - 1].Cells[0].Value = i.ToString(); } this.dgvSaleFlow.DataSource = bindingSaleFlow; //设置宽度 dgvSaleFlow.Columns["NO"].Width = 50; dgvSaleFlow.Columns["NO"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvSaleFlow.Columns["Product"].Width = 110; dgvSaleFlow.Columns["Product"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dgvSaleFlow.Columns["Count"].Width = 60; dgvSaleFlow.Columns["Count"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvSaleFlow.Columns["FixedPrice"].Width = 60; dgvSaleFlow.Columns["FixedPrice"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvSaleFlow.Columns["UnitPrice"].Width = 60; dgvSaleFlow.Columns["UnitPrice"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvSaleFlow.Columns["Calculate"].Width = 60; dgvSaleFlow.Columns["Calculate"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; }