private void button2_Click(object sender, EventArgs e) { if (dataGridView1.DataSource != null) { int rowindex = -1; for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Selected) { rowindex = i; break; } } if (rowindex >= 0) { DialogResult dr = MessageBox.Show("确认删除!第" + rowindex.ToString() + "数据?", "确认", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { Model.Paper_Store ps1 = DataSource.ORMHelper.RowToModel <Model.Paper_Store>(PaperData.Rows[rowindex]); Model.Paper_Store.Delete(ps1); PaperData.Rows.RemoveAt(rowindex); BindData(); } } } }
public static int paperout(DataTable OutPaper, bool NeedWritePaperOut, bool NeedUpdateStore, bool NeedUpdateMaterial) { int count = 0; if (OutPaper != null && OutPaper.Rows.Count > 0) { List <Paper_Out> paper = DataSource.ORMHelper.TbToModelList <Paper_Out>(OutPaper); List <string> AllorderList = new List <string>(); List <Model.Paper_Store> WaitOutPaer = new List <Model.Paper_Store>(); for (int i = 0; i < paper.Count; i++) { Model.Paper_Store ps = Model.Paper_Store.GetPaperById(paper[i].PaperId); string numno = paper[i].OrderNo; numno = numno.Replace("O", "PUB"); AllorderList.Add(numno); if (ps != null) { bool HadInsert = false; for (int k = 0; k < WaitOutPaer.Count; k++) { if (ps.PaperId == WaitOutPaer[k].PaperId) { WaitOutPaer[k].Num = WaitOutPaer[k].Num - paper[i].Num; WaitOutPaer[k].TaxiMoney -= paper[i].Money; HadInsert = true; break; } } if (!HadInsert) { ps.Num = ps.Num - paper[i].Num; //减去库存总金额; ps.TaxiMoney = ps.TaxiMoney - paper[i].Money; WaitOutPaer.Add(ps); } count++; } } //添加出库记录 if (NeedWritePaperOut) { Model.Paper_Out.InsertData(OutPaper); } //修改库存数量。PAPERSTROE里的数量更新; if (NeedUpdateStore) { foreach (Model.Paper_Store p1 in WaitOutPaer) { Model.Paper_Store.Update(p1); } } //修改材料表,表示已经出库;状态为1; if (NeedUpdateMaterial) { Model.P_MaterialList2.UpdateOut(AllorderList); } } return(count); }
private void button3_Click(object sender, EventArgs e) { DataTable upddata = AllOutPaper.Clone(); DialogResult dr = MessageBox.Show("确认将以下纸张全部撤销出库?", "提示", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes && dataGridView1.Rows.Count > 0) { DataTable OutPaper = (DataTable)dataGridView1.DataSource; List <Model.Paper_Out> OutPaperList = DataSource.ORMHelper.TbToModelList <Model.Paper_Out>(OutPaper); List <Model.Paper_Store> WaitOutPaer = new List <Model.Paper_Store>(); List <string> RemoveList = new List <string>(); int count = 0; for (int i = 0; i < OutPaperList.Count; i++) { Model.Paper_Store ps = Model.Paper_Store.GetPaperById(OutPaperList[i].PaperId); if (ps != null) { bool HadInsert = false; for (int k = 0; k < WaitOutPaer.Count; k++) { if (ps.PaperId == WaitOutPaer[k].PaperId) { WaitOutPaer[k].Num = WaitOutPaer[k].Num + OutPaperList[i].Num; WaitOutPaer[k].TaxiMoney += OutPaperList[i].Money; HadInsert = true; break; } } if (!HadInsert) { ps.Num = ps.Num + OutPaperList[i].Num; //减去库存总金额; ps.TaxiMoney = ps.TaxiMoney + OutPaperList[i].Money; WaitOutPaer.Add(ps); } RemoveList.Add(OutPaperList[i].Id.ToString()); count++; } } //添加出库记录 int result = Model.Paper_Out.RemoveOut(RemoveList); //修改库存数量。PAPERSTROE里的数量更新; foreach (Model.Paper_Store p1 in WaitOutPaer) { Model.Paper_Store.Update(p1); } button3.Enabled = false; if (result == count) { MessageBox.Show("您选择的" + count.ToString() + "已经全部撤销了出库!", "提示"); } } }
private void button6_Click(object sender, EventArgs e) { DataTable Alldata = (DataTable)dataGridView1.DataSource; if (Alldata != null) { if (Alldata.Rows.Count > 1) { List <Model.Paper_Store> NeedUpdatePaper = new List <Model.Paper_Store>(); List <Model.Store_month> AllStore = DataSource.ORMHelper.TbToModelList <Model.Store_month>(Alldata); foreach (Model.Store_month sm in AllStore) { if (sm.PaperId > 0 && sm.LastNum - sm.OutNum + sm.InNum != sm.CurrentNum) { Model.Paper_Store ps = Model.Paper_Store.GetPaperById(sm.PaperId); if (ps != null) { ps.Num = sm.LastNum - sm.OutNum + sm.InNum; ps.TaxiMoney = sm.LastMoney - sm.OutMoney + sm.InMoney; if (ps.Num != 0) { ps.TaxiPrice = Math.Abs(Math.Round(ps.TaxiMoney / ps.Num, 2)); } NeedUpdatePaper.Add(ps); } } } if (NeedUpdatePaper.Count > 0) { DialogResult dr = MessageBox.Show("本月当前库存数据即将强行平衡!是否继续?", "提示", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { foreach (Model.Paper_Store ps in NeedUpdatePaper) { Model.Paper_Store.Update(ps); } } } button6.Visible = false; } } }
private void button9_Click(object sender, EventArgs e) { if (comboBox2.SelectedItem == null) { MessageBox.Show("请先选择目标纸张!"); return; } if (comboBox3.SelectedItem == null) { MessageBox.Show("请先选择要修改的纸张!"); return; } int num = 0; if (!int.TryParse(textBox1.Text, out num)) { MessageBox.Show("请先输入要修改的纸张的数量!"); return; } Model.NameType SelectedPaper = (Model.NameType)comboBox2.SelectedItem; Model.Paper_Out OutPaper = (Model.Paper_Out)comboBox3.SelectedItem; Model.Paper_Store NewPaper = Model.Paper_Store.GetPaperById(SelectedPaper.Id); if (MaterialList != null) { Model.P_MaterialList2 pm2 = MaterialList[comboBox2.SelectedIndex]; pm2.StandName = SelectedPaper.Name; pm2.StandId = SelectedPaper.Id; pm2.UnitPrice = NewPaper.UnitPrice; pm2.Price = (int)Math.Round(OutPaper.Money, 0); pm2.Num = OutPaper.Num; if (DataSource.ORMHelper.UpdateModelById <Model.P_MaterialList2>(pm2) == 0) { DialogResult dr = MessageBox.Show("订单信息修改失败,确认是否继续修改出入库记录!", "确认", MessageBoxButtons.YesNo); if (dr != DialogResult.Yes) { return; } } } //读出新的纸张和老的纸张; //如果已经出库,还要修改出库记录,及库存记录; if (!NoOut) { Model.Paper_Store OldPaper = Model.Paper_Store.GetPaperById(OutPaper.PaperId); //修改相关记录; OldPaper.Num += OutPaper.Num; OldPaper.Money += OutPaper.Money; NewPaper.Num -= num; OutPaper.Num = num; OutPaper.Money = NewPaper.TaxiPrice * num; NewPaper.TaxiMoney -= OutPaper.Money; OutPaper.PaperId = NewPaper.PaperId; OutPaper.PaperName = NewPaper.PaperName; OutPaper.Price = NewPaper.TaxiPrice; if (Model.Paper_Out.Update(OutPaper) < 1) { MessageBox.Show("修改出库记录失败,确认后退出!"); return; } if (Model.Paper_Store.Update(OldPaper) + Model.Paper_Store.Update(NewPaper) == 2) { MessageBox.Show("修改出库记录及库存数据成功,确认后退出!"); } } }
public static int Paper_StroeIn(DataTable InPaper, bool NeedWritePaperIn, bool NeedUpdatePaperStroe) { List <Model.Paper_In> Ins = DataSource.ORMHelper.TbToModelList <Model.Paper_In>(InPaper); List <Model.Paper_Store> NeedUpdatePaper = new List <Paper_Store>(); int count = 0; foreach (Model.Paper_In pi in Ins) { if (pi.Num != 0) { Model.Paper_Store ps = Model.Paper_Store.GetPaperById(pi.PaperId); if (ps != null) { bool HadInsert = false; for (int k = 0; k < NeedUpdatePaper.Count; k++) { if (ps.PaperId == NeedUpdatePaper[k].PaperId) { NeedUpdatePaper[k].Num = NeedUpdatePaper[k].Num + pi.Num; NeedUpdatePaper[k].TaxiMoney = NeedUpdatePaper[k].TaxiMoney + pi.Money; HadInsert = true; break; } } if (!HadInsert) { //修改库存总数量; ps.Num = ps.Num + pi.Num; //修改库存总金额; ps.TaxiMoney += pi.Money; ps.TaxiPrice = Math.Abs(Math.Round(ps.TaxiMoney / ps.Num, 2)); //原基准价格的计算方法 //ps.UnitPrice = Math.Abs(Math.Round(ps.TaxiPrice * (decimal)1.16, 2)); //新基准价 ps.UnitPrice = pi.Price * (decimal)1.16; NeedUpdatePaper.Add(ps); } count++; } } } if (count == InPaper.Rows.Count) { int result1 = 0; int reulst2 = 0; //判断存入库表是否成功; if (NeedWritePaperIn) { result1 = InsertData(InPaper); } //判断存纸张表是否成功; if (NeedUpdatePaperStroe && result1 > 0) { foreach (Model.Paper_Store psu in NeedUpdatePaper) { if (Model.Paper_Store.Update(psu) > 0) { reulst2++; } } return(reulst2); } } return(0); }
private List <Model.Store_month> GetSinglePaperList(Model.Paper_Store paper, Model.Store_month LastStroe, List <Model.Paper_In> Allin, List <Model.Paper_Out> AllOut) { List <Model.Store_month> Result = new List <Model.Store_month>(); bool HaveData = false; //LastStroe.PaperName += "上月结余"; //Result.Add(LastStroe); if (LastStroe.LastNum != 0 || LastStroe.CurrentNum != 0) { HaveData = true; } int AllInNum = 0, AllOutNum = 0; decimal ALLInMoney = 0, AllOutMoney = 0; foreach (Model.Paper_In pi in Allin) { if (paper.PaperId == pi.PaperId) { Model.Store_month NewStroe = new Model.Store_month(); NewStroe.LastNum = LastStroe.LastNum; NewStroe.LastMoney = LastStroe.LastMoney; NewStroe.InNum = pi.Num; NewStroe.PaperId = paper.PaperId; NewStroe.PaperName = paper.PaperName; NewStroe.CalTime = pi.InTime; NewStroe.InMoney = pi.Money; Result.Add(NewStroe); AllInNum += pi.Num; ALLInMoney += pi.Money; HaveData = true; } } foreach (Model.Paper_Out po in AllOut) { if (paper.PaperId == po.PaperId) { Model.Store_month NewStroe = new Model.Store_month(); NewStroe.LastNum = LastStroe.LastNum; NewStroe.LastMoney = LastStroe.LastMoney; NewStroe.Price = LastStroe.Price; NewStroe.OutNum = po.Num; NewStroe.PaperId = paper.PaperId; NewStroe.PaperName = paper.PaperName; NewStroe.CalTime = po.OutTime; NewStroe.OutMoney = po.Money; int no = 0; if (int.TryParse(po.b1, out no)) { NewStroe.OrderNo = no; } else { NewStroe.OrderNo = 0; } Result.Add(NewStroe); AllOutNum += po.Num; AllOutMoney += po.Money; HaveData = true; } } Model.Store_month total = new Model.Store_month(); if (Result.Count == 0) { if (HaveData) { Result.Add(LastStroe); } } total.PaperName = "小计"; total.PaperId = LastStroe.PaperId; total.LastNum = LastStroe.LastNum; total.LastMoney = LastStroe.LastMoney; total.InMoney = ALLInMoney; total.InNum = AllInNum; total.OutNum = AllOutNum; total.OutMoney = AllOutMoney; total.CurrentNum = LastStroe.LastNum + AllInNum - AllOutNum; total.CurrentMoney = LastStroe.LastMoney + ALLInMoney - AllOutMoney; if (total.LastNum != 0) { total.CurrentPrice = Math.Round(total.LastMoney / total.LastNum, 2); } Result.Add(total); if (HaveData) { return(Result); } else { return(null); } }
private void button7_Click(object sender, EventArgs e) { int type = 0; //if (!(comboBox1.Items.Count > 0 && comboBox1.SelectedIndex >= 0)) //{ // MessageBox.Show("通过拼音简写选择要出库的纸张!", "提示"); // return; //} if (comboBox1.SelectedValue != null) { type = int.Parse(comboBox1.SelectedValue.ToString()); } else { type = 0; } DateTime LastTime = dateTimePicker1.Value.AddMonths(-1); //查上个月该品种库存的结存情况; List <Model.Store_month> AllStroe = Model.Store_month.GetMonthStoreList(LastTime); List <Model.Paper_Store> AllPaper = Model.Paper_Store.GetAllPaperList(); Model.Store_month LastStroe = null; Model.Paper_Store paper = null; bool LastOk = AllStroe != null && AllStroe.Count > 0; if (!LastOk) { DialogResult dr = MessageBox.Show("上月库存还没有结存!是否继续?如继续只汇总出入库情况!", "提示", MessageBoxButtons.YesNo); if (dr != DialogResult.Yes) { return; } else { LastStroe = new Model.Store_month(); } } else { if (type > 0) { paper = Model.Paper_Store.GetPaperById(type); for (int i = 0; i < AllStroe.Count; i++) { if (AllStroe[i].PaperId == type) { LastStroe = AllStroe[i]; break; } } } } //Model.Store_month LastStroe = Model.Store_month.GetPaperMonthStore(LastTime.Year, LastTime.Month, type); //如果没有上月结存。就创建个空的记录; LastTime = LastTime.AddMonths(1); List <Model.Paper_In> Allin = Model.Paper_In.GetYearMonthList(LastTime); List <Model.Paper_Out> AllOut = Model.Paper_Out.GetYearMonthList(LastTime); List <Model.Store_month> Result = new List <Model.Store_month>(); if (type > 0) { if (LastStroe == null) { LastStroe = new Model.Store_month(); } Result.AddRange(GetSinglePaperList(paper, LastStroe, Allin, AllOut)); } else { int AllInNum = 0, AllOutNum = 0, AllLastNum = 0; decimal ALLInMoney = 0, AllOutMoney = 0, AllLastMoney = 0; Model.Store_month total = new Model.Store_month(); total.PaperName = "总计"; for (int i = 0; i < AllPaper.Count; i++) { paper = AllPaper[i]; LastStroe = null; for (int j = 0; j < AllStroe.Count; j++) { if (AllStroe[j].PaperId == paper.PaperId) { LastStroe = AllStroe[j]; break; } } if (LastStroe == null) { LastStroe = new Model.Store_month(); } if (paper != null && LastStroe != null) { List <Model.Store_month> temp = GetSinglePaperList(paper, LastStroe, Allin, AllOut); if (temp != null) { Result.AddRange(temp); Model.Store_month t1 = temp[temp.Count - 1]; if (t1 != null) { AllInNum += t1.InNum; AllOutNum += t1.OutNum; AllOutMoney += t1.OutMoney; ALLInMoney += t1.InMoney; AllLastNum += t1.LastNum; AllLastMoney += t1.LastMoney; if (t1.LastNum + t1.InNum - t1.OutNum == t1.CurrentNum) { t1.OrderNo = 0; } else { t1.OrderNo = -1; } } } } } total.InMoney = ALLInMoney; total.InNum = AllInNum; total.OutNum = AllOutNum; total.OutMoney = AllOutMoney; total.LastNum = AllLastNum; total.LastMoney = AllLastMoney; total.CurrentNum = AllInNum + AllLastNum - AllOutNum; total.CurrentMoney = ALLInMoney + AllLastMoney - AllOutMoney; Result.Add(total); } DataTable dt = DataSource.ORMHelper.ModelListToTb <Model.Store_month>(Result); dataGridView1.DataSource = dt; List <string> title = Model.Store_month.GetColumNikeName(); int cindex = title.Count; for (int i = 0; i < cindex; i++) { dataGridView1.Columns[i].HeaderText = title[i]; } for (int j = 0; j < dt.Rows.Count; j++) { if (dt.Rows[j][cindex - 1].ToString() == "-1") { dataGridView1.Rows[j].DefaultCellStyle.ForeColor = Color.Red; } } CurrentData = dt; CurrentData.TableName = LastTime.Year.ToString() + "年" + LastTime.Month.ToString() + "月汇总表"; }
private void button4_Click(object sender, EventArgs e) { int type = 0; type = int.Parse(comboBox1.SelectedValue.ToString()); Model.Paper_Store paper = Model.Paper_Store.GetPaperById(type); if (!(comboBox1.Items.Count > 0 && comboBox1.SelectedIndex >= 0)) { MessageBox.Show("通过拼音简写选择要入库的纸张!", "提示"); return; } if (In == null) { In = new List <Model.Paper_In>(); } int num = 0; decimal price = 0, money = 0; bool inputok = true; inputok = inputok && int.TryParse(txt_num.Text, out num); inputok = inputok && decimal.TryParse(txt_money.Text, out money); if (!inputok) { MessageBox.Show("检查纸数量和金额!"); return; } price = decimal.Round(money / (decimal)num, 2); label12.Text = "纸张单价:" + price.ToString() + " 元"; Model.Paper_In pi = new Model.Paper_In() { Id = 0, Num = num, PaperId = paper.PaperId, PaperName = paper.PaperName, Price = price, Money = money, InTime = dateTimePicker1.Value, InCode = "手动单笔入库", FactorName = "系统" }; In.Add(pi); if (SaveTable == null) { DataTable InData = DataSource.ORMHelper.ModelListToTb <Model.Paper_In>(In); SaveTable = InData; } else { DataRow dr = DataSource.ORMHelper.ModelToRow <Model.Paper_In>(pi); SaveTable.ImportRow(dr); } dataGridView1.DataSource = SaveTable; SetInTitle(); txt_money.Text = ""; txt_num.Text = ""; }
private void button1_Click(object sender, EventArgs e) { try { int ptype = cbx_producter_type.SelectedIndex + 1;; PLen = int.Parse(text_Product_Len.Text); PWidth = int.Parse(text_Product_width.Text); num = int.Parse(text_producter_Num.Text); PageNum = int.Parse(text_Page_Num.Text); ColorNum = 0; if (checkBox2.Checked) { ColorNum = 0; } else { if (checkBox_c1.Checked) { ColorNum++; } if (checkBox_y1.Checked) { ColorNum++; } if (checkBox_k1.Checked) { ColorNum++; } if (checkBox_m1.Checked) { ColorNum++; } } op = new OrderPart(ptype, PLen, PWidth, num); op.PaperSource = checkBox_PaperSource.Checked; op.ColorNum = ColorNum; op.PageNum = PageNum; Model.NameType nt = (Model.NameType)comb_Paper.SelectedItem; op.PaperName = nt; if (op.MakePart()) { //检查页面数量的合法性;尤其是书本的开本和页数的关系;避免后面的计算出错 //checkPageNum() Model.Paper_Store paper = Model.Paper_Store.GetPaperById(nt.Id); Model.Rectange bp = new Model.Rectange(paper.Length, paper.Height); if (op.ProductType < 0) { MessageBox.Show("录入有错误,请重新检查输入项!"); return; } else { List <Model.NameType> needproces = Model.Process.GetProductProcess(ProductTypeId); if (needproces != null) { foreach (Model.NameType nt1 in needproces) { Model.PartItem pi = new Model.PartItem(); pi.PartType = 8; pi.PartName = "必选工艺"; pi.Name = nt1.Name; pi.Id = nt1.Id; pi.Num = num; pi.Price = 0; pi.Money = Model.C_ProcessPrice.GetProcessPrice(nt1.Id, num); op.AllItem.Add(pi); //op.AddProcess(nt1.Id); } } text_len.Text = op.Ps.Length.ToString(); text_width.Text = op.Ps.Width.ToString(); text_kaidu.Text = op.Ps.Kaidu.ToString(); text_needPaperNum1.Text = op.Part.PaperNum.ToString(); textBox_PsNum1.Text = op.AllPSnum.ToString(); textBox1.Text = op.AllPsSet.ToString(); text_lostnum.Text = op.Part.PaperExtend.ToString(); textBox2.Text = op.AllPrintNum.ToString(); BindView(); } } } catch { MessageBox.Show("录入有错误,请重新检查输入项!"); return; } }
private void button1_Click(object sender, EventArgs e) { Model.Paper_Store ps = new Model.Paper_Store(); ps.TypeId = cbx_type.SelectedIndex; string PaperName = ""; string StandName = ""; decimal unitprice = 0; int tonprice = 0; //ps.StandId = 98; ps.PaperFactory = text_factor.Text.Trim(); if (ps.PaperFactory.Length < 1) { MessageBox.Show("纸张品牌输入有误,检查输入!"); return; } if (comboBox1.SelectedIndex == 2) { PaperName = "非标"; int len = 0, width = 0; bool input = int.TryParse(text_len.Text, out len); input = input && int.TryParse(text_width.Text, out width); if (!input) { MessageBox.Show("自定义尺寸输入有误,检查输入!"); return; } else { ps.Length = len; ps.Height = width; } } if (comboBox1.SelectedIndex == 0) { PaperName = "大规"; ps.Length = 880; ps.Height = 1194; } if (comboBox1.SelectedIndex == 1) { PaperName = "正规"; ps.Length = 780; ps.Height = 1092; } int kg = 0; if (!int.TryParse(text_kg.Text, out kg)) { MessageBox.Show("纸张克重输入有误,检查输入!"); return; } ps.Kg = kg; PaperName += kg.ToString() + "g"; decimal price = 0; if (!decimal.TryParse(text_unitprice.Text, out price)) { MessageBox.Show("纸张销售价输入有误,检查输入!"); return; } //ps.UnitPrice = unitprice; StandName = PaperName; PaperName += text_factor.Text; string typename = cbx_type.Text; PaperName += typename; StandName += typename; ps.PaperName = PaperName; ps.StandId = 0; foreach (DataRow dr in allpaper.Rows) { if (ps.PaperName == dr["PaperName"].ToString()) { ps.StandId = int.Parse(dr["StandId"].ToString()); break; } } if (ps.StandId > 0) { MessageBox.Show("该纸张已经存在,请确认和检查输入!"); return; } foreach (Model.Paper_Stand psd in Allstand) { if (psd.StandName == StandName) { ps.StandId = psd.Id; } } if (ps.StandId == 0) { if (checkBox1.Checked) { unitprice = price; tonprice = decimal.ToInt32(Common.CalNumPreTon(ps.Length, ps.Height, ps.Kg) * unitprice); } else { tonprice = decimal.ToInt32(price); unitprice = Math.Round(price / Common.CalNumPreTon(ps.Length, ps.Height, ps.Kg), 2); } Model.Paper_Stand psd = new Model.Paper_Stand { StandName = StandName, KG = kg, SizeId = comboBox1.SelectedIndex + 1, TypeId = int.Parse(cbx_type.SelectedValue.ToString()) }; psd.SalesUnitPrice = unitprice; psd.SalesTonPrice = tonprice; DataSource.ORMHelper.InsertModel <Model.Paper_Stand>(psd); Allstand = Model.Paper_Stand.GetDataList("1=1"); foreach (Model.Paper_Stand psd1 in Allstand) { if (psd1.StandName == StandName) { ps.StandId = psd1.Id; break; } } } if (ps.StandId > 0) { ps.TonPrice = tonprice; ps.TypeId = cbx_type.SelectedIndex; if (ps.PaperName != null) { ps.PaperCode = Model.Common.GetChineseSpell(ps.PaperName); } if (Model.Paper_Store.InserData(ps) > 0) { MessageBox.Show(ps.PaperName + " 纸张已经添加!"); } else { MessageBox.Show(ps.PaperName + " 纸张添加失败!"); return; } for (int i = 0; i < AllProduct.Count; i++) { if (checkedListBox1.GetSelected(i)) { int id = AllProduct[i].ProductId; Model.R_ProductPaper rpp = new Model.R_ProductPaper() { ProductId = id, StandId = ps.StandId }; Model.R_ProductPaper.InserData(rpp); } } } //BindData(); }
private void button4_Click(object sender, EventArgs e) { int type = 0; type = int.Parse(comboBox1.SelectedValue.ToString()); Model.Paper_Store paper = Model.Paper_Store.GetPaperById(type); if (!(comboBox1.Items.Count > 0 && comboBox1.SelectedIndex >= 0)) { MessageBox.Show("通过拼音简写选择要出库的纸张!", "提示"); return; } if (Out == null) { Out = new List <Model.Paper_Out>(); } int num = 0; bool inputok = true; inputok = inputok && int.TryParse(txt_num.Text, out num); if (!inputok) { MessageBox.Show("检查纸数量!"); return; } if (paper.Num < num) { DialogResult dr = MessageBox.Show("即将出库的数量大于库存内数量,确认需要出库!", "提示", MessageBoxButtons.YesNo); if (dr != DialogResult.Yes) { return; } } Model.Paper_Out pi = new Model.Paper_Out() { Id = 0, Num = num, PaperId = paper.PaperId, PaperName = paper.PaperName, Price = paper.TaxiPrice, Money = paper.TaxiPrice * num, OutTime = dateTimePicker1.Value, RealTime = DateTime.Now, Remark = "手动单笔出库", b1 = "系统" }; Out.Add(pi); if (SaveTable == null) { DataTable InData = DataSource.ORMHelper.ModelListToTb <Model.Paper_Out>(Out); SaveTable = InData; } else { DataRow dr = DataSource.ORMHelper.ModelToRow <Model.Paper_Out>(pi); SaveTable.ImportRow(dr); } dataGridView1.DataSource = SaveTable; SetInTitle(); txt_num.Text = ""; }