Beispiel #1
0
        private void pictureBoxAddButton_Click(object sender, EventArgs e)
        {
            if (textBoxBrandId_AddStock.Text != "" && textBoxModelId_AddStock.Text != "" && textBoxFuelId_AddStock.Text != "" && textBoxEngineId_AddStock.Text != "" && textBoxCatId_AddStock.Text != "" && textBoxPartId_AddStock.Text != "" && textBoxYearId_AddStock.Text != "" && textBoxQuantityIn_AddStock.Text != "" && textBoxUnitPrice_AddStock.Text != "" &&
                comboBoxBrandName_AddStock.Text != "" && comboBoxModelName_AddStock.Text != "" && comboBoxFuelType_AddStock.Text != "" && comboBoxEngineCapacity_AddStock.Text != "" && comboBoxCatName_AddStock.Text != "" && comboBoxPartName_AddStock.Text != "" && comboBoxYear_AddStock.Text != "")
            {
                brand_id        = textBoxBrandId_AddStock.Text;
                model_id        = textBoxModelId_AddStock.Text;
                fuel_id         = textBoxFuelId_AddStock.Text;
                engine_id       = textBoxEngineId_AddStock.Text;
                year_id         = textBoxYearId_AddStock.Text;
                cat_id          = textBoxCatId_AddStock.Text;
                part_id         = textBoxPartId_AddStock.Text;
                quantity_in     = Convert.ToInt64(textBoxQuantityIn_AddStock.Text);
                unit_price      = Convert.ToInt64(textBoxUnitPrice_AddStock.Text);
                year            = comboBoxYear_AddStock.Text;
                brand_name      = comboBoxBrandName_AddStock.Text;
                model_name      = comboBoxModelName_AddStock.Text;
                fuel_type       = comboBoxFuelType_AddStock.Text;
                engine_capacity = comboBoxEngineCapacity_AddStock.Text;
                cat_name        = comboBoxCatName_AddStock.Text;
                part_name       = comboBoxPartName_AddStock.Text;
                string date = dateTimePicker_AddStock.Value.ToString();


                DatabaseConnections db = new DatabaseConnections();
                db.AddNewStock(brand_id, brand_name, model_id, model_name, fuel_id, fuel_type, engine_id, engine_capacity, year_id, year, cat_id, cat_name, part_id, part_name, quantity_in, unit_price, date);
            }

            else
            {
                MessageBox.Show("Can't keep empty feilds", "Warnning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            textBoxBrandId_AddStock.Text         = null;
            textBoxModelId_AddStock.Text         = null;
            textBoxFuelId_AddStock.Text          = null;
            textBoxEngineId_AddStock.Text        = null;
            textBoxYearId_AddStock.Text          = null;
            textBoxCatId_AddStock.Text           = null;
            textBoxPartId_AddStock.Text          = null;
            textBoxQuantityIn_AddStock.Text      = null;
            textBoxUnitPrice_AddStock.Text       = null;
            comboBoxBrandName_AddStock.Text      = null;
            comboBoxModelName_AddStock.Text      = null;
            comboBoxFuelType_AddStock.Text       = null;
            comboBoxEngineCapacity_AddStock.Text = null;
            comboBoxYear_AddStock.Text           = null;
            comboBoxCatName_AddStock.Text        = null;
            comboBoxPartName_AddStock.Text       = null;
        }
Beispiel #2
0
        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 = "";
            }
        }
Beispiel #3
0
        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 = "";
            }
        }
Beispiel #4
0
        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 = "";
            }
        }
Beispiel #5
0
        private void buttonGetItemcode_GenarateItemcode_Update_Click(object sender, EventArgs e)
        {
            string brand_name      = comboBoxBrandName_GenarateItemcode_Update.Text;
            string model_name      = comboBoxModelName_GenarateItemcode_Update.Text;
            string fuel_type       = comboBoxFuelType_GenarateItemcode_Update.Text;
            string engine_capacity = comboBoxEngineCapacity_GenarateItemcode_Update.Text;
            string year            = comboBoxYear_GenarateItemcode_Update.Text;
            string cat_name        = comboBoxCatName_GenarateItemcode_Update.Text;
            string part_name       = comboBoxPartName_GenarateItemcode_Update.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)
                {
                    textBox_ItemCode_UpdateStock.Text = Inventory_ItemCode;

                    comboBoxBrandName_GenarateItemcode_Update.Text      = null;
                    comboBoxModelName_GenarateItemcode_Update.Text      = null;
                    comboBoxFuelType_GenarateItemcode_Update.Text       = null;
                    comboBoxEngineCapacity_GenarateItemcode_Update.Text = null;
                    comboBoxYear_GenarateItemcode_Update.Text           = null;
                    comboBoxCatName_GenarateItemcode_Update.Text        = null;
                    comboBoxPartName_GenarateItemcode_Update.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);
            }
        }
Beispiel #6
0
        private void pictureBoxClearButton_Click(object sender, EventArgs e)
        {
            string itemCode       = textBox_ItemCode_ClearStock.Text;
            string repeatitemCode = textBox_RepeatItemCode_ClearStock.Text;
            string description    = textBoxDescription_ClearStock.Text;
            string date           = dateTimePicker_ClearItem.Value.ToString();

            if (itemCode == repeatitemCode && (itemCode != "" || repeatitemCode != ""))
            {
                DatabaseConnections db = new DatabaseConnections();
                long QuantityHand      = db.CheckQuantity(itemCode);

                DialogResult confirm = MessageBox.Show("ItemCode : " + itemCode + "\nQuantity on Hand : " + QuantityHand, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (confirm == DialogResult.Yes && QuantityHand > 0)
                {
                    DatabaseConnections db1 = new DatabaseConnections();
                    db1.Clearstock(itemCode);
                    db1.Delete_Clear_Details(itemCode, description, date, "Clear");
                    textBox_RepeatItemCode_ClearStock.Text = null;
                    textBox_ItemCode_ClearStock.Text       = null;
                    textBoxDescription_ClearStock.Text     = null;
                }

                else if (confirm == DialogResult.Yes && QuantityHand == 0)

                {
                    textBox_ItemCode_ClearStock.Text       = null;
                    textBox_RepeatItemCode_ClearStock.Text = null;
                    textBoxDescription_ClearStock.Text     = null;
                    MessageBox.Show("Item is Not In the Database\n         or \nItem Quantity is  0.\n\n\nCheck Item Code Again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                else
                {
                    textBox_ItemCode_ClearStock.Text       = null;
                    textBox_RepeatItemCode_ClearStock.Text = null;
                    textBoxDescription_ClearStock.Text     = null;
                }
            }

            else
            {
                MessageBox.Show("Check Item Code", "", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
            }
        }
        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);
            }
        }
Beispiel #8
0
        private void pictureBoxUpdateButton_Click(object sender, EventArgs e)
        {
            if (textBox_ItemCode_UpdateStock.Text != "" && textBox_QuantityIn_UpdateStock.Text != "")
            {
                string itemCode        = textBox_ItemCode_UpdateStock.Text;
                string QuantityIn      = textBox_QuantityIn_UpdateStock.Text;
                string date_time       = dateTimePicker_UpdateStock.Value.Date.ToShortDateString();
                long   Quan_in         = Convert.ToInt64(QuantityIn);
                DatabaseConnections db = new DatabaseConnections();
                long   QuantityHand    = db.CheckQuantity(itemCode);
                string Qh = Convert.ToString(QuantityHand);
                textBox_QuantityOnHand_UpdateStock.Text = Qh;
                if (QuantityHand != -1 && Quan_in > 0)
                {
                    DialogResult result1 = MessageBox.Show("Item Code : " + itemCode + "\nQuantity In : " + QuantityIn, "Verify Item Code and Quantity In", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (result1 == DialogResult.OK)
                    {
                        DatabaseConnections db2 = new DatabaseConnections();
                        db2.UpdateStock(itemCode, QuantityIn, date_time);
                        textBox_ItemCode_UpdateStock.Text       = null;
                        textBox_QuantityIn_UpdateStock.Text     = null;
                        textBox_QuantityOnHand_UpdateStock.Text = null;
                    }
                    if (result1 == DialogResult.Cancel)
                    {
                        textBox_ItemCode_UpdateStock.Text       = null;
                        textBox_QuantityIn_UpdateStock.Text     = null;
                        textBox_QuantityOnHand_UpdateStock.Text = null;
                    }
                }
                else if (Quan_in < 0 && QuantityHand != -1)
                {
                    MessageBox.Show("Invalid Qunanty In... Qunatity In Can't be less than 0", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                else
                {
                    DialogResult result2 = MessageBox.Show("Check Item code : " + itemCode, "Invalid Item Code", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                    if (result2 == DialogResult.Retry)
                    {
                        textBox_ItemCode_UpdateStock.Text       = null;
                        textBox_QuantityIn_UpdateStock.Text     = null;
                        textBox_QuantityOnHand_UpdateStock.Text = null;
                    }

                    if (result2 == DialogResult.Cancel)
                    {
                        this.Hide();
                    }
                }
            }
            else
            {
                if (textBox_ItemCode_UpdateStock.Text != "")
                {
                    MessageBox.Show("Enter data to Quantity in data Field!", "Warnnig", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                else if (textBox_QuantityIn_UpdateStock.Text != "")
                {
                    MessageBox.Show("Enter data to ItemCode data Field!", "Warnnig", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show("Can't keep empty data Field!\n Enter ItemCode and Quantity In", "Warnnig", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Beispiel #9
0
        private void pictureBoxDeleteButton_Click(object sender, EventArgs e)
        {
            String itemCode       = textBox_ItemCode_DeleteStock.Text;
            String repeatitemCode = textBox_RepeatItemCode_DeleteStock.Text;
            string description    = textBoxDescription_DeleteItem.Text;
            string date           = dateTimePicker_DeleteItem.Value.ToString();

            if (itemCode == repeatitemCode && (itemCode != "" || repeatitemCode != ""))
            {
                DatabaseConnections db = new DatabaseConnections();
                long QuantityHand      = db.CheckQuantity(itemCode);


                DialogResult result1 = MessageBox.Show("ItemCode : " + itemCode + "\n Item Name : " + db.getItemDetails_String(itemCode), "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (result1 == DialogResult.Yes && QuantityHand == 0)
                {
                    DatabaseConnections db1 = new DatabaseConnections();
                    textBox_ItemCode_DeleteStock.Text       = null;
                    textBox_RepeatItemCode_DeleteStock.Text = null;
                    textBoxDescription_DeleteItem.Text      = null;
                    db1.DeleteItem(itemCode);
                    db1.Delete_Clear_Details(itemCode, description, date, "Delete");
                }
                else if (result1 == DialogResult.Yes && QuantityHand > 0)
                {
                    DialogResult result = MessageBox.Show("Item Quantity is  " + QuantityHand + " Please clear the stock before delete the Item.", "Warnning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    if (result == DialogResult.OK)
                    {
                        Stock_Control stock = new Stock_Control(4);
                        stock.Show();
                    }

                    else
                    {
                        this.Hide();
                        textBox_ItemCode_DeleteStock.Text       = null;
                        textBox_RepeatItemCode_DeleteStock.Text = null;
                        textBoxDescription_DeleteItem.Text      = null;
                    }
                }

                else if (result1 == DialogResult.Yes && QuantityHand == -1)
                {
                    MessageBox.Show("Invalid ItemCode", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    textBox_ItemCode_DeleteStock.Text       = null;
                    textBox_RepeatItemCode_DeleteStock.Text = null;
                    textBoxDescription_DeleteItem.Text      = null;
                }


                else
                {
                    textBox_ItemCode_DeleteStock.Text       = null;
                    textBox_RepeatItemCode_DeleteStock.Text = null;
                    textBoxDescription_DeleteItem.Text      = null;
                }
            }

            else
            {
                MessageBox.Show("Check Item Code", "", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
            }
        }