private async void button_Inventory_Save_Click(object sender, EventArgs e) { foreach (DataGridViewRow x in dataGridView_Inventory.Rows) { CSeller_Inventory y = (CSeller_Inventory)(x.Cells["extra_1"].Value); await y.Commit(Double.Parse(x.Cells["price"].Value.ToString()), Int32.Parse(x.Cells["quantity"].Value.ToString()), Int32.Parse(x.Cells["pincode"].Value.ToString()), Double.Parse(x.Cells["warranty"].Value.ToString())); } }
private async void button_Main_Click(object sender, EventArgs e) { if (!ButtonState) { // Check Constraints if (String.IsNullOrWhiteSpace(textBox_Name.Text)) { MessageBox.Show("Invalid Name!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (comboBox_Catagory.SelectedIndex < 0) { MessageBox.Show("Invalid Catagory!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (String.IsNullOrWhiteSpace(richTextBox_Description.Text)) { MessageBox.Show("Invalid Description!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } foreach (extFieldStruct x in extField) { if (String.IsNullOrWhiteSpace(x.textBox.Text)) { { MessageBox.Show("Invalid " + x.label.Text + "!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } } if (pictureBox_Picture.Image == null || pictureBox_Picture.Image.Equals(global::OPS.Properties.Resources.noimage)) { MessageBox.Show("Invalid Image!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // Register Product if (!(await CProduct.Register(((CCatagory)comboBox_Catagory.SelectedItem).id, textBox_Name.Text, richTextBox_Description.Text, pictureBox_Picture.Image))) { if (CUtils.LastLogMsg != null) { MessageBox.Show("Cause: " + CUtils.LastLogMsg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Cause: Unknown", "Failed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } return; } item = await CProduct.Retrieve(((CCatagory)comboBox_Catagory.SelectedItem).id, textBox_Name.Text); if (item == null) { if (CUtils.LastLogMsg != null) { MessageBox.Show("Cause: " + CUtils.LastLogMsg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Cause: Unknown", "Failed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } return; } // Lock Product Specifications textBox_Name.ReadOnly = true; comboBox_Catagory.Enabled = false; richTextBox_Description.ReadOnly = true; foreach (extFieldStruct x in extField) { x.textBox.ReadOnly = true; } button_Browse.Visible = false; // Change Form & Button State tableLayoutPanel2.Visible = true; button_Main.Text = "Add To Inventory"; ButtonState = true; } else { if (!CUtils.IsNumeric(textBox_Price.Text)) { MessageBox.Show("Invalid Price!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!CUtils.IsNumeric(textBox_Quantity.Text)) { MessageBox.Show("Invalid Quantity!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (comboBox_Pincode.SelectedIndex < 0) { MessageBox.Show("Invalid Pincode!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!CUtils.IsNumeric(textBox_Warranty.Text)) { MessageBox.Show("Invalid Warranty!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Console.WriteLine("QUAT=" + Int32.Parse(textBox_Quantity.Text)); if (!(await CSeller_Inventory.Register(CUser.cur_user.id, item.id, Double.Parse(textBox_Price.Text), Int32.Parse(textBox_Quantity.Text), ((CLocation)comboBox_Pincode.SelectedItem).pincode, Double.Parse(textBox_Warranty.Text)))) { if (CUtils.LastLogMsg.Equals("Inventory Already Exists!")) { CSeller_Inventory inv = await CSeller_Inventory.Retrieve(CUser.cur_user.id, item.id); if (inv != null) { if (!(await inv.Commit(inv.price, inv.quantity + Int32.Parse(textBox_Quantity.Text), inv.pincode, inv.warranty))) { MessageBox.Show("Successfully Added to Inventory!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Visible = false; this.Dispose(); return; } } MessageBox.Show("Cause: Unknown", "Failed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (CUtils.LastLogMsg != null) { MessageBox.Show("Cause: " + CUtils.LastLogMsg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Cause: Unknown", "Failed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } return; } MessageBox.Show("Successfully Added to Inventory!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Visible = false; this.Dispose(); } }
private async void button_AddToInventory_Click(object sender, EventArgs e) { if (!CUtils.IsNumeric(textBox_Price.Text)) { MessageBox.Show("Invalid Price!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!CUtils.IsNumeric(textBox_Quantity.Text)) { MessageBox.Show("Invalid Quantity!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (comboBox_Pincode.SelectedIndex < 0) { MessageBox.Show("Invalid Pincode!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!CUtils.IsNumeric(textBox_Warranty.Text)) { MessageBox.Show("Invalid Warranty!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (invitem != null) { if (!(await invitem.Commit(invitem.price, invitem.quantity + Int32.Parse(textBox_Quantity.Text), invitem.pincode, invitem.warranty))) { if (CUtils.LastLogMsg != null) { MessageBox.Show("Cause: " + CUtils.LastLogMsg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Cause: Unknown", "Failed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } return; } } else if (!(await CSeller_Inventory.Register(CUser.cur_user.id, item.id, Double.Parse(textBox_Price.Text), Int32.Parse(textBox_Quantity.Text), ((CLocation)comboBox_Pincode.SelectedItem).pincode, Double.Parse(textBox_Warranty.Text)))) { if (CUtils.LastLogMsg == null || CUtils.LastLogMsg.Equals("Inventory Already Exists!")) { MessageBox.Show("Cause: Unknown", "Failed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("Cause: " + CUtils.LastLogMsg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; } MessageBox.Show("Successfully Added to Inventory!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Visible = false; this.Dispose(); }