Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        private void textBox_QuantityIn_UpdateStock_MouseClick(object sender, MouseEventArgs e)
        {
            string itemCode        = textBox_ItemCode_UpdateStock.Text;
            DatabaseConnections db = new DatabaseConnections();
            long   QuantityHand    = db.CheckQuantity(itemCode);
            string Qh = Convert.ToString(QuantityHand);

            textBox_QuantityOnHand_UpdateStock.Text = Qh;
        }
Beispiel #3
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 #5
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 #6
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);
            }
        }