private void toolStripButton1_Click(object sender, EventArgs e) { this.dataGridView1.CurrentCell = null; List <SalesOrderMateriel> list = new List <SalesOrderMateriel>(); for (int i = 0; i < this.dataGridView1.RowCount; i++) { if (this.dataGridView1.Rows[i].Cells["price"].Value == DBNull.Value || this.dataGridView1.Rows[i].Cells["quantity"].Value == DBNull.Value) { MessageBox.Show("物料缺失价格或数量!"); return; } SalesOrderMateriel lm = new SalesOrderMateriel(); lm.price = Math.Round(Convert.ToDouble(this.dataGridView1.Rows[i].Cells["price"].Value), 2); lm.materiel = Convert.ToInt32(this.dataGridView1.Rows[i].Cells["id"].Value); lm.quantity = Convert.ToDouble(this.dataGridView1.Rows[i].Cells["quantity"].Value); if (this.dataGridView1.Rows[i].Cells["combination"].Value != DBNull.Value) { lm.combination = Convert.ToInt32(this.dataGridView1.Rows[i].Cells["combination"].Value); } lm.attrs = this.dataGridView1.Rows[i].Cells["solidbacking"].Value.ToString(); list.Add(lm); } var msg = ctrl.setList(order, label12.Text, label5.Text, label9.Text, list); MessageBox.Show(msg.Msg); }
private void toolStripButton1_Click(object sender, EventArgs e) { this.dataGridView1.CurrentCell = null; if (this.dataGridView1.RowCount == 0) { MessageBox.Show("请添加物料!"); return; } else if (this.customer == "") { MessageBox.Show("请添加客户!"); return; } SalesOrder obj = new SalesOrder(customer, user, richTextBox1.Text, dateTimePicker1.Value, dateTimePicker2.Value); obj.listM = new List <SalesOrderMateriel>(); for (int i = this.dataGridView1.RowCount; i > 0; i--) { var line = Convert.ToInt32(this.dataGridView1.Rows[i - 1].Cells["line"].Value); SalesOrderMateriel lm = new SalesOrderMateriel(); lm.line = line; lm.price = Math.Round(Convert.ToDouble(this.dataGridView1.Rows[i - 1].Cells["price"].Value), 2); lm.materiel = Convert.ToInt32(this.dataGridView1.Rows[i - 1].Cells["id"].Value); lm.quantity = Convert.ToDouble(this.dataGridView1.Rows[i - 1].Cells["quantity"].Value); if (this.dataGridView1.Rows[i - 1].Cells["summary"].Value != null) { lm.summary = this.dataGridView1.Rows[i - 1].Cells["summary"].Value.ToString(); } lm.tax = Convert.ToDouble(this.dataGridView1.Rows[i - 1].Cells["tax"].Value); lm.deliveryDate = Convert.ToDateTime(this.dataGridView1.Rows[i - 1].Cells["deliveryDate"].Value); if (lm.price == 0 || lm.quantity == 0) { MessageBox.Show("物料缺失价格或数量!"); return; } var num = 0; var attrnum = Convert.ToInt32(this.dataGridView1.Rows[i - 1].Cells["attrnum"].Value); if (mapAttr.Keys.Contains(line)) { num = mapAttr[line].Keys.Count; } if (num < attrnum) { MessageBox.Show("请添加辅助属性!"); return; } if (attrnum > 0) { lm.combination = sbctrl.getCombin(lm.materiel, mapAttr[line]); } obj.listM.Add(lm); } var msg = sctrl.add(obj); if (msg.Code == 0) { //this.Hide(); MessageBox.Show(msg.Msg); toolStripButton1.Enabled = false; toolStripButton2.Enabled = false; toolStripButton3.Enabled = false; dateTimePicker1.Enabled = false; dateTimePicker2.Enabled = false; button1.Enabled = false; textBox1.Enabled = false; richTextBox1.Enabled = false; dataGridView1.ReadOnly = true; DataTable dtorder = sctrl.getlastinsert(PropertyClass.UserId); label7.Visible = true; label9.Text = dtorder.Rows[0]["num"].ToString(); double amount = 0; for (int i = 0; i < this.dataGridView1.RowCount; i++) { amount += Convert.ToDouble(this.dataGridView1.Rows[i].Cells["amount"].Value); } sctrl.addMsg(label5.Text, label9.Text, textBox1.Text, dateTimePicker2.Value.ToString(), amount); } else { MessageBox.Show(msg.Msg); } }