private void button3_Click(object sender, EventArgs e) { button5.Visible = false; List <Model.Paper_In> Allin = Model.Paper_In.GetYearMonthList(dateTimePicker1.Value); Model.Paper_In total = new Model.Paper_In(); total.PaperName = "汇总"; foreach (Model.Paper_In pi in Allin) { total.Num += pi.Num; total.Money += pi.Money; } Allin.Add(total); CurrentData = DataSource.ORMHelper.ModelListToTb <Model.Paper_In>(Allin); dataGridView1.DataSource = CurrentData; List <string> title = Model.Paper_In.GetColumNikeName(); for (int i = 0; i < title.Count; i++) { dataGridView1.Columns[i].HeaderText = title[i]; } CurrentData.TableName = "入存汇总表"; }
private void button4_Click(object sender, EventArgs e) { Canin = null; if (inputdata != null) { int NameColIndex = -1; int NumColIndex = -1; int MoneyColIndex = -1; int DateColIndex = -1; int.TryParse(name_col.Text, out NameColIndex); int.TryParse(num_col.Text, out NumColIndex); int.TryParse(money_col.Text, out MoneyColIndex); int.TryParse(datecol.Text, out DateColIndex); try { if (isincol(NameColIndex) && isincol(NumColIndex) && isincol(MoneyColIndex) && isincol(DateColIndex)) { if (inputdata.Columns.Count > 0) { NameColIndex = NameColIndex - 1; NumColIndex = NumColIndex - 1; MoneyColIndex = MoneyColIndex - 1; DateColIndex = DateColIndex - 1; allpaper.PrimaryKey = new DataColumn[] { allpaper.Columns["PaperId"] }; List <Model.Paper_In> allin = new List <Model.Paper_In>(); Canin = inputdata.Clone(); foreach (DataRow dr in inputdata.Rows) { string papername = dr[NameColIndex].ToString(); Model.Paper_In pi = new Model.Paper_In(); pi.PaperName = papername; pi.PaperId = -1; DataRow dr1 = null; foreach (DataRow dr2 in allpaper.Rows) { if (dr2["PaperName"].ToString() == papername) { dr1 = dr2; break; } } if (dr1 != null) { pi.PaperId = int.Parse(dr1["PaperId"].ToString()); pi.Num = int.Parse(dr[NumColIndex].ToString()); pi.Money = decimal.Parse(dr[MoneyColIndex].ToString()); if (pi.Num == 0) { continue; } pi.Price = Math.Abs(pi.Money / pi.Num); pi.Price = decimal.Round(pi.Price, 2); pi.RealTime = DateTime.Now; pi.InTime = DateTime.Parse(dr[DateColIndex].ToString()); pi.FactorName = "系统自动"; allin.Add(pi); } else { Canin.ImportRow(dr); } } if (allin.Count > 0) { dtin = DataSource.ORMHelper.ModelListToTb <Model.Paper_In>(allin); if (dtin != null) { dataGridView1.DataSource = dtin; List <string> title = Model.Paper_In.GetColumNikeName(); for (int i = 0; i < title.Count; i++) { dataGridView1.Columns[i].HeaderText = title[i]; } } } else { dtin = null; } } } } catch { MessageBox.Show("请检查输入文件的格式,或重新输入队列对应关系!"); } } }
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 button3_Click(object sender, EventArgs e) { DataTable inputdata = (DataTable)dataGridView1.DataSource; DataTable AllInput = null; if (inputdata != null) { int NameColIndex = -1; int NumColIndex = -1; int MoneyColIndex = -1; int DateColIndex = -1; int.TryParse(name_col.Text, out NameColIndex); int.TryParse(num_col.Text, out NumColIndex); int.TryParse(money_col.Text, out MoneyColIndex); int.TryParse(datecol.Text, out DateColIndex); int MaxCount = inputdata.Columns.Count; try { if (isincol(NameColIndex, MaxCount) && isincol(NumColIndex, MaxCount) && isincol(MoneyColIndex, MaxCount) && isincol(DateColIndex, MaxCount)) { if (inputdata.Columns.Count > 0) { NameColIndex = NameColIndex - 1; NumColIndex = NumColIndex - 1; MoneyColIndex = MoneyColIndex - 1; DateColIndex = DateColIndex - 1; List <Model.Paper_Store> allpaper = Model.Paper_Store.GetAllPaperList(); List <Model.Paper_In> allin = new List <Model.Paper_In>(); foreach (DataRow dr in inputdata.Rows) { string papername = dr[NameColIndex].ToString(); int index = -1; for (int i = 0; i < allpaper.Count; i++) { if (allpaper[i].PaperName == papername) { index = i; break; } } if (index >= 0) { Model.Paper_In pi = new Model.Paper_In(); pi.PaperName = papername; pi.PaperId = allpaper[index].PaperId; pi.Num = int.Parse(dr[NumColIndex].ToString()); pi.Money = decimal.Parse(dr[MoneyColIndex].ToString()); if (pi.Num == 0) { continue; } pi.Price = Math.Abs(pi.Money / pi.Num); pi.Price = decimal.Round(pi.Price, 2); pi.RealTime = DateTime.Now; pi.InTime = dateTimePicker1.Value; pi.FactorName = "系统初始化"; allin.Add(pi); } } if (allin.Count > 0) { AllInput = DataSource.ORMHelper.ModelListToTb <Model.Paper_In>(allin); } if (AllInput != null) { dataGridView1.DataSource = AllInput; List <string> title = Model.Paper_In.GetColumNikeName(); for (int i = 0; i < title.Count; i++) { dataGridView1.Columns[i].HeaderText = title[i]; } dataGridView1.AutoResizeColumns(); button2.Enabled = true; } } } } catch { MessageBox.Show("请检查输入文件的格式,或重新输入队列对应关系!"); } } }