private void BindList() { VipSoft.BLL.Goods bllGoods = new BLL.Goods(); DataSet ds = bllGoods.GetList(pageSize, currentPage, out resCount, condition); this.dataGridView_List.DataSource = ds.Tables[0]; for (int i = 0; i < dataGridView_List.Rows.Count; i++) { dataGridView_List.Rows[i].Cells[0].Value = false; } DataTable dts = ds.Tables[0]; int T = 0; //库存数量 int X = 0; //销售数量 decimal J = 0; //进货金额 decimal P = 0; //销售金额 for (int i = 0; i < dts.Rows.Count; i++) { int Tnum = int.Parse(dts.Rows[i]["Number"].ToString()); int Xnum = int.Parse(dts.Rows[i]["SaleNumber"].ToString() == "" ? "0" : dts.Rows[i]["SaleNumber"].ToString()); decimal JinhuoPrice = Math.Round(decimal.Parse(dts.Rows[i]["BuyPrice"].ToString()), 2); decimal XiaoshouPrice = Math.Round(decimal.Parse(dts.Rows[i]["Price"].ToString()), 2); T += Tnum; X += Xnum; J += Tnum * JinhuoPrice; P += Xnum * XiaoshouPrice; } this.lbl_TotalNum.Text = T.ToString(); this.lbl_XiaoNum.Text = X.ToString(); this.lbl_jinhuo.Text = J.ToString("¥0.00"); this.lbl_xiaoshou.Text = P.ToString("¥0.00"); BindPage(); }
private void button_Save_Click(object sender, EventArgs e) { if (!CheckInput()) return; VipSoft.BLL.Goods bllGoods = new BLL.Goods(); VipSoft.Model.Goods model = new Model.Goods(); model.GoodsCode=this.textBox_GoodsCode.Text.Trim(); model.Name = this.textBox_GoodsName.Text.Trim(); model.NameCode = this.textBox_NameCode.Text.Trim(); model.ClassID = int.Parse(this.comboBox_Class.SelectedValue.ToString()); model.Unit = this.comboBox_Unit.Text == null ? this.comboBox_Unit.SelectedItem.ToString() : this.comboBox_Unit.Text; model.Number = int.Parse(this.textBox_Number.Text); model.Point = int.Parse(this.textBox_Point.Text); model.Price = decimal.Parse(this.textBox_Price.Text.Replace("¥", "")); model.BuyPrice = decimal.Parse(this.myMoneyTextBox1.Text.Replace("¥", "")); model.MinPercent = decimal.Parse(this.textBox_MinPercent.Text); model.PointType = int.Parse(this.rdoIsPoint.Checked ? "1" : "0"); model.GoodsType = this.checkBox_GoodsType.Checked?(byte)0:(byte)1; model.ShopID = PublicState.Master.ShopID; model.ShopName = PublicState.Master.ShopName; if (CurrentGoodsID == 0) { if (bllGoods.Exists(this.textBox_GoodsCode.Text.Trim())) { MessageBox.Show("编号为" + this.textBox_GoodsCode.Text + "的产品或服务已经存在,请重新输入编号或增加其他的产品。"); this.textBox_GoodsCode.Focus(); this.textBox_GoodsCode.SelectAll(); } if (bllGoods.Add(model) > 0) { // 加入日志 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master, "产品入库", string.Format("产品添加,编号:{0}名称:{1}数量:{2}", model.GoodsCode, this.textBox_GoodsName.Text, this.textBox_Number.Text), DateTime.Now)); // 提示 MessageBox.Show("产品添加成功。"); // 刷新 if (GoodsListRefresh != null) GoodsListRefresh(); } else { MessageBox.Show("产品添加失败,请重试。"); return; } } else { model.ID = CurrentGoodsID; if (bllGoods.Update(model)) { // 日志记录 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new VipSoft.Model.SysLog(PublicState.Master, "产品信息修改", "修改产品信息(编号:" + this.textBox_GoodsCode.Text + " 名称:" + this.textBox_GoodsName.Text + ")", DateTime.Now)); // 提示 MessageBox.Show("产品信息修改成功。"); // 刷新 if (GoodsListRefresh != null) GoodsListRefresh(); } else { MessageBox.Show("产品信息修改失败,请重试。"); return; } } // 窗口处理 if (this.checkBox_save.Checked) { this.checkBox_AutoCode.Checked = false; this.textBox_GoodsCode.Text = ""; this.textBox_GoodsName.Text = ""; this.textBox_Number.Text = "0"; this.textBox_Point.Text = "0"; this.textBox_MinPercent.Text = "0"; this.textBox_Price.Text = "¥0.00"; this.myMoneyTextBox1.Text = "¥0.00"; this.textBox_MinPercent.Text = "0"; } else this.Close(); }