예제 #1
0
        private void okbtn_Click(object sender, EventArgs e)
        {
            if (donebytxt.Text.Trim() == "" || reasontxt.Text.Trim() == "")
            {
                MessageBox.Show("Cannot process this transaction. Please write fill up the given field.", "Transaction Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                SyspassTxt.Text = "";
            }

            else if (SyspassTxt.Text != password)
            {
                MessageBox.Show("Cannot process this transaction. Make sure that your password is correct!.", "Transaction Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                SyspassTxt.Text = "";
                SyspassTxt.Focus();
            }
            else
            {
                BalloonKingdomDataSetTableAdapters.Inventory_TransactionsTableAdapter addDupItem = new WindowsApplication1.BalloonKingdomDataSetTableAdapters.Inventory_TransactionsTableAdapter();
                addDupItem.AddnewInventoryTrans(Convert.ToInt32(IDtxt.Text), ItemNmetxt.Text, "Adding", Convert.ToInt32(qtytxt.Text), DateTime.Now, donebytxt.Text.Trim(), reasontxt.Text.Trim());

                BalloonKingdomDataSetTableAdapters.InventoryTableAdapter addnewitem = new WindowsApplication1.BalloonKingdomDataSetTableAdapters.InventoryTableAdapter();
                addnewitem.AddNewInventoryRec(iid, icat, isub, ispec, iname, itype, isize, iqty, iunit, Convert.ToDecimal(iunitprice), Convert.ToDecimal(isellingprice), Convert.ToDecimal(istock), istatus, icolor, Convert.ToDecimal(iwidth), Convert.ToDecimal(iheight), isup);
                MessageBox.Show("New Item has been added!", "Inventory Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
        }
        private void okbtn_Click(object sender, EventArgs e)
        {
            if (donebytxt.Text.Trim() == "")
            {
                MessageBox.Show("Cannot process this transaction. Please write your name in the given field.", "Transaction Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else if (SyspassTxt.Text != syspass)
            {
                MessageBox.Show("Cannot process this transaction. Make sure that your password is correct!.", "Transaction Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                SyspassTxt.Text = "";
            }
            else
            {
                int    InvQty = 0;
                double stockQty = 0, total = 0, totalstock = 0;
                double UP = 0;
                string status;


                SqlCommand    cmd25 = new SqlCommand("Select * from Inventory where [Item ID]=" + "'" + Convert.ToString(IDtxt.Text) + "'", conn);
                SqlDataReader dr25  = cmd25.ExecuteReader();
                while (dr25.Read())
                {
                    InvQty   = Convert.ToInt32(dr25["Quantity"].ToString());
                    stockQty = Convert.ToDouble(dr25["Quantity in Stock"].ToString());
                    UP       = Convert.ToDouble(dr25["Unit Price"].ToString());
                }

                dr25.Close();

                total      = Convert.ToDouble(InvQty) + Convert.ToDouble(qtytxt.Text.Trim());
                totalstock = stockQty + Convert.ToDouble(qtytxt.Text.Trim());

                if (total != 0)
                {
                    status = "available";
                }
                else
                {
                    status = "unavailable";
                }
                BalloonKingdomDataSetTableAdapters.InventoryTableAdapter updateDuplicateItem = new WindowsApplication1.BalloonKingdomDataSetTableAdapters.InventoryTableAdapter();



                updateDuplicateItem.UpdateDuplicateItem(Convert.ToInt32(total), Convert.ToInt32(totalstock), status, Convert.ToInt32(IDtxt.Text), Convert.ToInt32(IDtxt.Text));

                MessageBox.Show("Duplicate Item has been updated!", "Inventory Information", MessageBoxButtons.OK, MessageBoxIcon.Information);


                BalloonKingdomDataSetTableAdapters.Inventory_TransactionsTableAdapter addDupItem = new WindowsApplication1.BalloonKingdomDataSetTableAdapters.Inventory_TransactionsTableAdapter();
                addDupItem.AddnewInventoryTrans(Convert.ToInt32(IDtxt.Text), ItemNmetxt.Text, "Adding", Convert.ToInt32(qtytxt.Text), DateTime.UtcNow, donebytxt.Text.Trim(), "Add Quantity to Duplicate Item");
                updateDuplicateItem.UpdateDuplicateItem(Convert.ToInt32(total), Convert.ToInt32(totalstock), status, Convert.ToInt32(IDtxt.Text), Convert.ToInt32(IDtxt.Text));


                this.Close();
            }
        }
예제 #3
0
        private void okbtn_Click(object sender, EventArgs e)
        {
            if (donebytxt.Text.Trim() == "" || reasontxt.Text.Trim() == "" || qtytxt.Text.Trim() == "")
            {
                MessageBox.Show("Cannot process this transaction. Please write fill up the given field.", "Transaction Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Syspasstxt.Text = "";
            }

            else if (Syspasstxt.Text != password)
            {
                MessageBox.Show("Cannot process this transaction. Make sure that your password is correct!.", "Transaction Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Syspasstxt.Text = "";
                Syspasstxt.Focus();
            }
            else
            {
                string trans;
                if (addbtn.Checked == true)
                {
                    trans = "Adding";
                }
                else
                {
                    trans = "Subtracting";
                }



                int           quantity = Convert.ToInt32(qtytxt.Text.Trim());
                double        qty = 0, stock = 0, bo = 0;
                SqlCommand    getinv = new SqlCommand("Select * from Inventory where [Item ID]=" + "'" + idlbl.Text.Trim() + "'", conn);
                SqlDataReader drget  = getinv.ExecuteReader();
                while (drget.Read())
                {
                    qty   = Convert.ToDouble(drget["Quantity"].ToString());
                    stock = Convert.ToDouble(drget["Quantity in Stock"].ToString());
                    bo    = Convert.ToDouble(drget["Back Order"].ToString());
                }
                drget.Close();

                if (addbtn.Checked == true)
                {
                    qty   += quantity;
                    stock += Convert.ToDouble(quantity);
                    bo    -= Convert.ToDouble(quantity);
                    if (bo < 0)
                    {
                        bo = 0;
                    }
                }
                else
                {
                    qty   -= quantity;
                    stock -= Convert.ToDouble(quantity);
                    if (stock == 0)
                    {
                        stock = 0;
                        bo   += Convert.ToDouble(quantity);
                    }
                }
                BalloonKingdomDataSetTableAdapters.Inventory_TransactionsTableAdapter addInvItem = new WindowsApplication1.BalloonKingdomDataSetTableAdapters.Inventory_TransactionsTableAdapter();
                addInvItem.AddnewInventoryTrans(Convert.ToInt32(idlbl.Text), txtname.Text, trans, Convert.ToInt32(qtytxt.Text), DateTime.Now, donebytxt.Text.Trim(), reasontxt.Text.Trim());


                BalloonKingdomDataSetTableAdapters.InventoryTableAdapter update = new WindowsApplication1.BalloonKingdomDataSetTableAdapters.InventoryTableAdapter();
                update.UpdateInvQuantity(Convert.ToInt32(qty), Convert.ToDecimal(stock), Convert.ToInt32(bo), Convert.ToInt32(idlbl.Text.Trim()), Convert.ToInt32(idlbl.Text.Trim()));
                MessageBox.Show("Successfully updated Inventory Item Quantity", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
        }