Пример #1
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);
            }
        }
Пример #2
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);
            }
        }