Example #1
0
        //Margo
        private void btnlogin_Click(object sender, EventArgs e)
        {
            try
            {
                lblReason.Visible  = false;
                lblProject.Visible = false;
                bool check = true;
                if (textBox1.Text == "")
                {
                    lblReason.Visible = true;
                    check             = false;
                }

                if (textBox2.Text == "")
                {
                    lblProject.Visible = true;
                    check = false;
                }

                if (check == true)
                {
                    int         BookOutID = current.BookOutID;
                    LTS.BookOut bo        = new LTS.BookOut();
                    bo = DAT.DataAccess.GetBookOut().Where(u => u.BookOutID == BookOutID).FirstOrDefault();
                    if (bo != null)
                    {
                        bo.Reason  = textBox1.Text;
                        bo.Project = textBox2.Text;

                        bool update = DAT.DataAccess.UpdateBookOut(bo);
                        if (update)
                        {
                            MessageBox.Show("The book out update was succesful!");
                            ((Main)this.Parent.Parent).ChangeView <Pages.StockOut.StockOut>();
                        }
                        else
                        {
                            MessageBox.Show("The book out update was unsuccesful!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("The book out update was unsuccesful!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sorry Something went wrong, the action was not completed!");
            }
        }
Example #2
0
 public static LTS.BookOut GetBookOutItemByID(int?BookOutID)
 {
     LTS.BookOut bookOut = new LTS.BookOut();
     try
     {
         using (LTS.LTSBase access = new LTS.LTSDC())
         {
             bookOut = access.BookOut.Where(o => o.BookOutID == BookOutID).FirstOrDefault();
         }
     }
     catch (Exception ex)
     {
     }
     return(bookOut);
 }
Example #3
0
        public static int AddBookOut(LTS.BookOut bookOut)
        {
            int?BookOutID = -1;

            try
            {
                using (LTS.LTSBase access = new LTS.LTSDC())
                {
                    access.InsertBookOut(bookOut.Date, bookOut.ItemID, bookOut.Project, bookOut.Reason, bookOut.UserID, ref BookOutID);
                }
            }
            catch (Exception ex)
            {
            }
            return(BookOutID.Value);
        }
Example #4
0
        public static bool UpdateBookOut(LTS.BookOut bookOut)
        {
            bool completed = false;

            try
            {
                using (LTS.LTSBase access = new LTS.LTSDC())
                {
                    access.UpdateBookOut(bookOut.Date, bookOut.ItemID, bookOut.Project, bookOut.Reason, bookOut.UserID, bookOut.BookOutID);
                    completed = true;
                }
            }
            catch (Exception ex)
            {
                completed = false;
            }
            return(completed);
        }
Example #5
0
        //Tiaan
        private void btnlogin_Click(object sender, EventArgs e)
        {
            try
            {
                bool ok = true;
                labelError1.Visible = false;
                labelError2.Visible = false;
                labelError3.Visible = false;
                //change item status to false
                //make bookOut record
                if (textBox1.Text == "")
                {
                    labelError1.Text    = "Please enter Booking Out Reason!";
                    labelError1.Visible = true;
                    ok = false;
                }
                if (textBox2.Text == "")
                {
                    labelError2.Text    = "Please enter Project Name!";
                    labelError2.Visible = true;
                    ok = false;
                }
                if (dataGridView1.SelectedRows.Count == 0)
                {
                    labelError3.Text    = "Please select a row from the list!";
                    labelError3.Visible = true;
                    ok = false;
                }
                else if (ok)
                {
                    LTS.BookOut checkOut = new LTS.BookOut();

                    LTS.Item p = new LTS.Item();
                    p = DAT.DataAccess.GetItem().Where(y => y.ItemID == current.itemID).FirstOrDefault();

                    if (p != null)
                    {
                        checkOut.Reason  = textBox1.Text;
                        checkOut.Project = textBox2.Text;
                        checkOut.Date    = DateTime.Today;
                        checkOut.UserID  = ((Form1)this.Parent.Parent.Parent.Parent).loggedIn.UserID;
                        checkOut.ItemID  = p.ItemID;

                        int check = DAT.DataAccess.AddBookOut(checkOut);
                        if (check != -1)
                        {
                            p.ItemStatus = false;

                            bool itemUpdate = DAT.DataAccess.UpdateItem(p);
                            if (itemUpdate)
                            {
                                MessageBox.Show("The product was successfully booked out!");
                                ((Main)this.Parent.Parent).ChangeView <Pages.StockOut.StockOut>();
                            }
                            else
                            {
                                bool remove = DAT.DataAccess.RemoveBookOut(check);
                                MessageBox.Show("Sorry something went wrong, the product was not booked out!");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Sorry something went wrong, the product was not booked out!");
                            ((Main)this.Parent.Parent).ChangeView <BookStockOut>();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sorry Something went wrong, the action was not completed!");
            }
        }