private void buttonGetItemcode_GenarateItemcode_Clear_Click(object sender, EventArgs e) { string brand_name = comboBoxBrandName_GenarateItemcode_Clear.Text; string model_name = comboBoxModelName_GenarateItemcode_Clear.Text; string fuel_type = comboBoxFuelType_GenarateItemcode_Clear.Text; string engine_capacity = comboBoxEngineCapacity_GenarateItemcode_Clear.Text; string year = comboBoxYear_GenarateItemcode_Clear.Text; string cat_name = comboBoxCatName_GenarateItemcode_Clear.Text; string part_name = comboBoxPartName_GenarateItemcode_Clear.Text; string Inventory_ItemCode; if (brand_name != "" && model_id != "" && fuel_type != "" && engine_capacity != "" && year != "" && cat_name != "" && part_name != "") { DatabaseConnections db = new DatabaseConnections(); string Brand_id = db.GetId(brand_name, "Brand"); string Model_id = db.GetId(model_name, "Model"); string Fuel_id = db.GetId(fuel_type, "Fuel"); string Engine_Id = db.GetId(engine_capacity, "Engine"); string Year_id = db.GetId(year, "Year"); string Cat_id = db.GetId(cat_name, "Category"); string Part_id = db.GetId(part_name, "SparePart"); Inventory_ItemCode = Brand_id + Model_id + Fuel_id + Engine_Id + Year_id + Cat_id + Part_id; long QuantityHand = db.CheckQuantity(Inventory_ItemCode); if (QuantityHand >= 0) { if (textBox_ItemCode_ClearStock.Text.Length == 21 && checkBox_Repeat_Clear.Checked) { textBox_RepeatItemCode_ClearStock.Text = Inventory_ItemCode; } else { textBox_ItemCode_ClearStock.Text = Inventory_ItemCode; } comboBoxBrandName_GenarateItemcode_Clear.Text = null; comboBoxModelName_GenarateItemcode_Clear.Text = null; comboBoxFuelType_GenarateItemcode_Clear.Text = null; comboBoxEngineCapacity_GenarateItemcode_Clear.Text = null; comboBoxYear_GenarateItemcode_Clear.Text = null; comboBoxCatName_GenarateItemcode_Clear.Text = null; comboBoxPartName_GenarateItemcode_Clear.Text = null; } else { MessageBox.Show("Check all the fiels. Invalid Itemcode.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Can't keep empty fields", "Warinning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void comboBoxYear_AddStock_TextChanged(object sender, EventArgs e) { string check = comboBoxYear_AddStock.Text; if (check != "") { DatabaseConnections db = new DatabaseConnections(); string ItemId5 = db.GetId(check, "Year"); textBoxYearId_AddStock.Text = ItemId5; } else { textBoxYearId_AddStock.Text = ""; } }
private void comboBoxPartName_AddStock_TextChanged(object sender, EventArgs e) { string check = comboBoxPartName_AddStock.Text; if (check != "") { DatabaseConnections db = new DatabaseConnections(); string ItemId7 = db.GetId(check, "SparePart"); textBoxPartId_AddStock.Text = ItemId7; } else { textBoxPartId_AddStock.Text = ""; } }
private void comboBoxEngineCapacity_AddStock_TextChanged(object sender, EventArgs e) { string check = comboBoxEngineCapacity_AddStock.Text; if (check != "") { DatabaseConnections db = new DatabaseConnections(); string ItemId4 = db.GetId(check, "Engine"); textBoxEngineId_AddStock.Text = ItemId4; } else { textBoxEngineId_AddStock.Text = ""; } }
private void button6_AddItem_Click(object sender, EventArgs e) { string brand_name = comboBox_BrandName.Text; string model_name = comboBox2_model.Text; string fuel_type = comboBox3_fuel.Text; string engine_capacity = comboBox4_engine.Text; string year = comboBox5_year.Text; string cat_name = comboBox6_category.Text; string part_name = comboBox7_part.Text; string Inventory_ItemCode; if (brand_name != "" && model_name != "" && fuel_type != "" && engine_capacity != "" && year != "" && cat_name != "" && part_name != "") { String[] ar = new String[4]; DatabaseConnections db = new DatabaseConnections(); string Brand_id = db.GetId(brand_name, "Brand"); string Model_id = db.GetId(model_name, "Model"); string Fuel_id = db.GetId(fuel_type, "Fuel"); string Engine_Id = db.GetId(engine_capacity, "Engine"); string Year_id = db.GetId(year, "Yearr"); string Cat_id = db.GetId(cat_name, "Category"); string Part_id = db.GetId(part_name, "SparePart"); Inventory_ItemCode = Brand_id + Model_id + Fuel_id + Engine_Id + Year_id + Cat_id + Part_id; ar[0] = Inventory_ItemCode; ar[1] = db.getItemDetails_String(Inventory_ItemCode); ar[2] = db.get_unit_price("100" + Inventory_ItemCode); //MessageBox.Show(Inventory_ItemCode); long QuantityHand = db.CheckQuantity(Inventory_ItemCode); if (QuantityHand >= 0) { int quantity = Convert.ToInt32(quantity_box.Text); ar[3] = quantity.ToString(); int total = Convert.ToInt32(total_box.Text); int unit_pr = Convert.ToInt32(ar[2]); // to get the sum total = total + unit_pr * quantity; //set total total_box.Text = total.ToString(); // things to do :deduct from stock/print bill/record to log/ clear row etc. ListViewItem itm = new ListViewItem(ar); listView1.Items.Add(itm); comboBox_BrandName.Text = null; comboBox2_model.Text = null; comboBox3_fuel.Text = null; comboBox4_engine.Text = null; comboBox5_year.Text = null; comboBox6_category.Text = null; comboBox7_part.Text = null; quantity_box.Text = null; } else { MessageBox.Show("Check all the fiels. Invalid Itemcode.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Can't keep empty fields", "Warinning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }