Example #1
0
        void PopulateDatagridviewData()
        {
            using (NatiSupermarketandTakeawayFinalEntities db = new NatiSupermarketandTakeawayFinalEntities())
            {
                var dgvQuery = (from Items in db.Inventory_Item
                                join Price in db.Inventory_Price
                                on Items.Inventory_Item_ID equals Price.Inventory_Item_ID
                                join Type in db.Inventory_Item_Type
                                on Items.Inventory_Item_Type_ID equals Type.Inventory_Item_Type_ID
                                //where ed.Employee_Details_Name.Contains(txtESearch.Text)
                                select new { Items.Inventory_Item_ID, Items.Inventory_Item_Barcode, Items.Inventory_Item_Name, Price.Inventory_Price1, Type.Inv_Item_Type_Description }
                                ).ToList();

                //dgvInventoryItem.DataSource = db.Inventory_Item.ToList<Inventory_Item>();
                //dgvInventoryItem.DataSource = db.Inventory_Price.ToList<Inventory_Price>();
                //dgvInventoryItem.DataSource = db.Inventory_Item_Type.ToList<Inventory_Item_Type>();
                dgvInventoryItem.Columns.Clear();
                dgvInventoryItem.DataSource    = dgvQuery;
                dgvInventoryItem.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

                dgvInventoryItem.Columns[0].HeaderText = "Inventory ID";
                dgvInventoryItem.Columns[1].HeaderText = "Inventory Barcode";
                dgvInventoryItem.Columns[1].Width      = 100;
                dgvInventoryItem.Columns[2].HeaderText = "Inventory Name";
                dgvInventoryItem.Columns[2].Width      = 100;
                dgvInventoryItem.Columns[3].HeaderText = "Discount";
                dgvInventoryItem.Columns[4].HeaderText = "Price (Per Unit)";
                dgvInventoryItem.Columns[4].Width      = 100;
                dgvInventoryItem.Columns[5].HeaderText = "Type";
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                using (NatiSupermarketandTakeawayFinalEntities db = new NatiSupermarketandTakeawayFinalEntities())
                {
                    var dgvQuery = (from Items in db.Inventory_Item
                                    where Items.Inventory_Item_Name.Contains(txtSearchInventoryItem.Text)
                                    select new { Items.Inventory_Item_ID, Items.Inventory_Item_Name, Items.Inventory_Item_Quantity }
                                    ).ToList();

                    dgvInventoryStockTake.Columns.Clear();
                    dgvInventoryStockTake.DataSource    = dgvQuery;
                    dgvInventoryStockTake.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

                    dgvInventoryStockTake.Columns[0].HeaderText = "Inventory ID";
                    dgvInventoryStockTake.Columns[1].HeaderText = "Inventory Name";
                    dgvInventoryStockTake.Columns[1].Width      = 100;
                    dgvInventoryStockTake.Columns[2].HeaderText = "Quantity";
                    dgvInventoryStockTake.Columns[2].Width      = 100;
                }
            }
            catch (Exception myErr)
            {
                MessageBox.Show("Error: " + myErr.Message);
            }
        }
Example #3
0
        void PopulateInvDGV()
        {
            try
            {
                using (NatiSupermarketandTakeawayFinalEntities db = new NatiSupermarketandTakeawayFinalEntities())
                {
                    var dgvQuery = (from Items in db.Inventory_Item
                                    select new { Items.Inventory_Item_ID, Items.Inventory_Item_Name, Items.Inventory_Item_Quantity }
                                    ).ToList();

                    dgvInventoryStockTake.Columns.Clear();
                    dgvInventoryStockTake.DataSource    = dgvQuery;
                    dgvInventoryStockTake.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

                    dgvInventoryStockTake.Columns[0].HeaderText = "Inventory ID";
                    dgvInventoryStockTake.Columns[1].HeaderText = "Inventory Name";
                    dgvInventoryStockTake.Columns[1].Width      = 100;
                    dgvInventoryStockTake.Columns[2].HeaderText = "Quantity";
                    dgvInventoryStockTake.Columns[2].Width      = 100;
                }
            }
            catch (Exception myErr)
            {
                MessageBox.Show("Error: " + myErr.Message);
            }
        }
 void PopSecurityQuestionCbx()
 {
     using (NatiSupermarketandTakeawayFinalEntities db = new NatiSupermarketandTakeawayFinalEntities())
     {
         var cbxQuery = (from secQ in db.Security_Question
                         select new { secQ.Security_Question_Description }
                         ).ToList();
         cbxSecQuest.DataSource    = cbxQuery;
         cbxSecQuest.DisplayMember = "Security_Question_Description";
     }
 }
Example #5
0
 private void btnFinaliseSale_Click(object sender, EventArgs e)
 {
     //POSForm frmSale = new POSForm("","",1, txtSalesDescription.Text, txtSalesQuantity.Text, txtSalesPrice.Text,txtSalesDiscount.Text,"","","","");
     //frmSale.Show();
     #region Saving to database
     Invmodel.Inventory_Item_Name = txtSalesDescription.Text.Trim();
     //Invmodel.Inventory_Item_Barcode = txtBarcode.text.trim();
     Invmodel.Inventory_Item_Quantity = Convert.ToInt32(txtSalesQuantity.Text.Trim());
     Pricemodel.Inventory_Price1      = Convert.ToDecimal(txtSalesPrice.Text.Trim());
     using (NatiSupermarketandTakeawayFinalEntities db = new NatiSupermarketandTakeawayFinalEntities())
     {
         db.Inventory_Item.Add(Invmodel);
         db.Inventory_Price.Add(Pricemodel);
         db.Inventory_Item_Type.Add(TypeModel);
         db.SaveChanges();
     }
 }
        private void btnChangePassword_Click(object sender, EventArgs e)
        {
            try
            {
                using (NatiSupermarketandTakeawayFinalEntities db = new NatiSupermarketandTakeawayFinalEntities())
                {
                    db.spChangeEmployeePassword(txtPassword.Text, txtEmail.Text, DateTime.Today.Date, DateTime.Now.TimeOfDay, txtName.Text, "Change of Password", "Password was changed.");

                    db.SaveChanges();
                    MessageBox.Show("You have successfully changed your password.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error in chnaging the password. Error:" + ex);
            }
        }
Example #7
0
        public bool CanLogin()
        {
            using (NatiSupermarketandTakeawayFinalEntities db = new NatiSupermarketandTakeawayFinalEntities())
            {
                bool CanLogin  = false;
                int  ExisQuery = (from el in db.Employees
                                  where el.Employee_Name.Equals(txtName.Text.Trim())
                                  select new { el.Employee_ID, el.Employee_Name, el.Employee_Login_Password, el.Employee_Picture }
                                  ).Count();

                if (ExisQuery > 0)
                {
                    var LoginQuery = (from et in db.Employee_Type
                                      join ua in db.Employee_Access_Level
                                      on et.Employee_Access_Level_ID equals ua.Employee_Access_Level_ID
                                      join emp in db.Employees
                                      on et.Employee_Type_ID equals emp.Employee_Type_ID
                                      where emp.Employee_Name.Equals(txtName.Text.Trim())
                                      select new { emp.Employee_ID, emp.Employee_Name, emp.Employee_Login_Password, emp.Employee_Picture, ua.Employee_Access_Level_ID }
                                      ).First();

                    Employee_Access_Level = LoginQuery.Employee_Access_Level_ID;
                    Employee_ID           = LoginQuery.Employee_ID;
                    Employee_Name         = LoginQuery.Employee_Name;
                    Employee_Password     = LoginQuery.Employee_Login_Password;
                    Employee_Picture      = LoginQuery.Employee_Picture;

                    if (LoginQuery.Employee_Name == txtName.Text.Trim() && Convert.ToBase64String(LoginQuery.Employee_Login_Password) == PasswordHash(txtPassword.Text.Trim()))
                    {
                        CanLogin = true;
                    }
                    else
                    {
                        CanLogin = false;
                        MessageBox.Show("Error: Incorrect UserName or Password, Please Check Spelling");
                    }
                }

                return(CanLogin);
            }
        }
        public bool ChangePassword()
        {
            using (NatiSupermarketandTakeawayFinalEntities db = new NatiSupermarketandTakeawayFinalEntities())
            {
                bool ChangePassword = false;
                int  ExisQuery      = (from el in db.Employees
                                       where el.Employee_Email.Equals(txtEmail.Text.Trim())
                                       select new { el.Employee_ID, el.Employee_Email, el.Security_Question }
                                       ).Count();

                if (ExisQuery > 0)
                {
                    var LoginQuery = (from sq in db.Security_Question
                                      join emp in db.Employees
                                      on sq.Security_Question_ID equals emp.Security_Question_ID
                                      where emp.Employee_Name.Equals(txtName.Text.Trim())
                                      select new { emp.Employee_ID, emp.Employee_Name, emp.Employee_Email, sq.Security_Question_Description, emp.Employee_Security_Answer }
                                      ).First();


                    if (LoginQuery.Employee_Name == txtName.Text.Trim() && LoginQuery.Employee_Email == txtEmail.Text.Trim() && LoginQuery.Security_Question_Description == cbxSecQuest.Text.Trim() && LoginQuery.Employee_Security_Answer == txtAnswer.Text)
                    {
                        ChangePassword = true;
                        Employee_ID    = LoginQuery.Employee_ID;
                    }
                    else
                    {
                        ChangePassword = false;
                        MessageBox.Show("Error: Incorrect details or not entered details. Please reconfirm all the details on the form.");
                    }
                }
                else
                {
                    ChangePassword = false;
                    MessageBox.Show("Error: Incorrect email or security question response, Please Check Spelling");
                }

                return(ChangePassword);
            }
        }
Example #9
0
 private void btnUpdateQuantity_Click(object sender, EventArgs e)
 {
     //if (MessageBox.Show("Are you sure you want to update this quantity?","Confirmation",MessageBoxButtons.YesNo) == "Yes"
     using (NatiSupermarketandTakeawayFinalEntities db = new NatiSupermarketandTakeawayFinalEntities())
     {
         try
         {
             int id       = Convert.ToInt32(dgvInventoryStockTake.SelectedRows[0]);
             var UpdateST = (from item in db.Inventory_Item
                             where id == item.Inventory_Item_ID
                             select item).First();
             UpdateST.Inventory_Item_Quantity = Convert.ToInt32(nudQuantityST.Value);
             db.SaveChanges();
             PopulateInvDGV();
             this.Close();
         }
         catch (Exception ss)
         {
             MessageBox.Show(ss.ToString());
         }
     }
 }