Example #1
0
        private void Txt_numOfSeat_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Return)
            {
                if (validateInput())
                {
                    string floorId     = cb_floor.SelectedValue.ToString();
                    string tableZoneId = cb_zone.SelectedValue.ToString();
                    string tableName   = Encrption.trim(txt_tablename.Text.ToString());
                    string numOfSeat   = Encrption.trim(txt_numOfSeat.Text.ToString());

                    if (this.is_edit.Equals(true))
                    {
                        Tables tables = new Tables(this.table_id, floorId, tableZoneId, tableName, numOfSeat);
                        if (Convert.ToBoolean(tables.updateTable()).Equals(true))
                        {
                            MessageBox.Show("Table has updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                    }
                    else
                    {
                        Tables tables = new Tables(floorId, tableZoneId, tableName, numOfSeat);
                        if (Convert.ToBoolean(tables.addTable()).Equals(true))
                        {
                            MessageBox.Show("Table has created successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                    }
                }
            }
        }
 private void SearchEnterPressEventOccure(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar.Equals((char)Keys.Return))
     {
         Customer customer;
         if (txt_search.Text.ToString().Length > 0)
         {
             customer = new Customer();
             DataTable dataTable = customer.searchCustomer(Encrption.trim(txt_search.Text.ToString()), cb_search.SelectedItem.ToString());
             if (dataTable.Rows.Count > 0)
             {
                 btn_clear.Show();
                 this.customerGridViewFormatting(dataTable);
             }
             else
             {
                 MessageBox.Show("No record(s) found", "Infomation", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         else
         {
             customer = null;
             MessageBox.Show(String.Format("Please enter keyword to search by {0}", cb_search.SelectedItem.ToString()), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txt_search.Focus();
             this.loadCustomer();
         }
     }
 }
 private void btnt_search_Click(object sender, EventArgs e)
 {
     if (txtt_search.Text.ToString().Length > 0)
     {
         DataTable data = tables.searchTable(Encrption.trim(txtt_search.Text.ToString()), cbt_search.SelectedItem.ToString());
         if (data.Rows.Count > 0)
         {
             btnt_clear.Show();
             refreshTable(data);
         }
         else
         {
             MessageBox.Show(String.Format("No record(s) found", cbt_search.SelectedItem.ToString()), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
             btnt_clear.Hide();
             txtt_search.Clear();
             txtt_search.Focus();
             refreshTable(tables.getTables());
         }
     }
     else
     {
         MessageBox.Show(String.Format("Please enter keyword to search by {0}", cbt_search.SelectedItem.ToString()), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
         btnt_clear.Hide();
         txtt_search.Clear();
         txtt_search.Focus();
         refreshTable(tables.getTables());
     }
 }
 private void EnterKeyPressEventOccure(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar.Equals((char)Keys.Return))
     {
         items = new Items();
         if (txt_search.Text.ToString().Length > 0)
         {
             DataTable data = items.searchItem(Encrption.trim(txt_search.Text.ToString()), cb_search.SelectedItem.ToString());
             if (data.Rows.Count > 0)
             {
                 is_search = true;
                 btn_clear.Show();
                 LoadItems(data);
             }
             else
             {
                 MessageBox.Show("No record(s) found", "Infomation", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         else
         {
             MessageBox.Show(String.Format("Please enter keyword to search by {0}", cb_search.SelectedItem.ToString()), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txt_search.Focus();
             LoadItems(items.getItems());
         }
     }
 }
 private void txtf_search_TextChanged(object sender, EventArgs e)
 {
     if (txtf_search.Text.ToString().Length > 0)
     {
         refreshFloor(floor.searchFloor(Encrption.trim(txtf_search.Text.ToString())));
     }
     else
     {
         refreshFloor(floor.getFloor());
     }
 }
        private void Txt_zonename_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Return)
            {
                string floor_id  = cb_floor.SelectedValue.ToString();
                string zone_name = Encrption.trim(txt_zonename.Text.ToString());

                if (zone_name.Length > 0)
                {
                    if (zone_name.Length > 191)
                    {
                        MessageBox.Show("Zone name is too long", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        if (int.TryParse(zone_name, out int result))
                        {
                            MessageBox.Show("Zone name must be alphabetic", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            if (is_edit.Equals(true))
                            {
                                TableZone tableZone = new TableZone(tablezone_id, floor_id, zone_name);
                                if (Convert.ToBoolean(tableZone.updateTableZone()).Equals(true))
                                {
                                    MessageBox.Show("Table zone updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    this.Close();
                                }
                            }
                            else
                            {
                                TableZone tableZone = new TableZone(floor_id, zone_name);
                                if (Convert.ToBoolean(tableZone.addTableZone()).Equals(true))
                                {
                                    MessageBox.Show("Table zone created successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    this.Close();
                                }
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please enter zone name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
 private void btn_search_Click(object sender, EventArgs e)
 {
     if (txtz_search.Text.ToString().Length > 0)
     {
         btn_clear.Show();
         refreshZone(tableZone.searchZone(Encrption.trim(txtz_search.Text.ToString()), cbz_search.SelectedItem.ToString()));
     }
     else
     {
         MessageBox.Show(String.Format("Please enter keyword to search by {0}", cbz_search.SelectedItem.ToString()), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
         btn_clear.Hide();
         txtz_search.Clear();
         txtz_search.Focus();
         refreshZone(tableZone.getTableZone());
     }
 }
 private void PressEnterOccure(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)Keys.Return)
     {
         string category_name = Encrption.trim(txtc_name.Text.ToString());
         if (category_name.Length > 0)
         {
             if (category_name.Length > 191)
             {
                 MessageBox.Show("Category name is too long", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 if (int.TryParse(category_name, out int result))
                 {
                     MessageBox.Show("Category name must be alphabetic", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 else
                 {
                     if (this.is_edit.Equals(true))
                     {
                         Category category = new Category(this.category_id, category_name, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                         if (Convert.ToBoolean(category.updateCategory()).Equals(true))
                         {
                             MessageBox.Show("Category has updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                             this.DialogResult = DialogResult.OK;
                             this.Close();
                         }
                     }
                     else
                     {
                         Category category = new Category(category_name, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                         if (Convert.ToBoolean(category.addCategory()).Equals(true))
                         {
                             MessageBox.Show("Category has created successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                             this.Close();
                         }
                     }
                 }
             }
         }
         else
         {
             MessageBox.Show("Please enter category", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Example #9
0
        private void EnterKeyPressEventOccure(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Return)
            {
                if (this.validateUser())
                {
                    if (this.verifiedUser == true)
                    {
                        if (txt_cpassword.Text.ToString().Length > 0)
                        {
                            if (txt_password.Text.ToString().Length < 6 || txt_password.Text.ToString().Length > 20)
                            {
                                string name        = Encrption.trim(txt_name.Text.ToString());
                                string username    = Encrption.trim(txt_username.Text.ToString());
                                string email       = Encrption.trim(txt_email.Text.ToString());
                                string user_role   = Login.user_role;
                                string user_status = Login.user_status;
                                string password    = txt_cpassword.Text.ToString();
                                string created_at  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                                users = new Users(Login.user_id, name, username, email, password, user_role, user_status, created_at);
                                if (users.updateUser() > 0)
                                {
                                    MessageBox.Show("Account has been updated", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    confirmPasswordlbl.Visible = false;
                                    txt_cpassword.Visible      = false;
                                    txt_password.Clear();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Password must be in between 6 to 20 characters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please enter new password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter valid password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
 private void Txt_floor_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)Keys.Return)
     {
         string floor_name = Encrption.trim(txt_floor.Text.ToString());
         if (floor_name.Length > 0)
         {
             if (floor_name.Length > 191)
             {
                 MessageBox.Show("Floor name is too long", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 if (int.TryParse(floor_name, out int result))
                 {
                     MessageBox.Show("Floor name must be alphabetic", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 else
                 {
                     if (is_edit.Equals(true))
                     {
                         Floor floor = new Floor(floor_id, floor_name);
                         if (Convert.ToBoolean(floor.updateFloor()).Equals(true))
                         {
                             MessageBox.Show("Floor has updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                             this.Close();
                         }
                     }
                     else
                     {
                         Floor floor = new Floor(floor_id, floor_name);
                         if (Convert.ToBoolean(floor.addFloor(floor_name)).Equals(true))
                         {
                             MessageBox.Show("Floor has created successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                             this.Close();
                         }
                     }
                 }
             }
         }
         else
         {
             MessageBox.Show("Please enter floor name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
 private void ZoneSearchEnterEventOccure(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar.Equals((char)Keys.Return))
     {
         if (txtz_search.Text.ToString().Length > 0)
         {
             btn_clear.Show();
             refreshZone(tableZone.searchZone(Encrption.trim(txtz_search.Text.ToString()), cbz_search.SelectedItem.ToString()));
         }
         else
         {
             MessageBox.Show(String.Format("Please enter keyword to search by {0}", cbz_search.SelectedItem.ToString()), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
             btn_clear.Hide();
             txtz_search.Clear();
             txtz_search.Focus();
             refreshZone(tableZone.getTableZone());
         }
     }
 }
        private void EnterKeyPressEventOccure(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Return)
            {
                if (this.validateInput())
                {
                    string name            = Encrption.trim(txt_name.Text.ToString());
                    string email           = Encrption.trim(txt_email.Text.ToString());
                    string address         = Encrption.trim(txt_address.Text.ToString());
                    string phone           = Encrption.trim(txt_phone.Text.ToString());
                    string additional_info = Encrption.trim(txt_additionalInfo.Text.ToString());

                    if (this.isCustomerEdit == true)
                    {
                        string updated_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        customer = new Customer(int.Parse(this.customerId), name, phone, address, email, additional_info, updated_at);
                        int result = customer.updateCustomer();
                        if (result > 0)
                        {
                            MessageBox.Show("Customer has updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.nullInputFied();
                            this.Close();
                        }
                    }
                    else
                    {
                        string created_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        string updated_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                        customer = new Customer(name, phone, address, email, additional_info, created_at, updated_at);
                        int result = customer.addCustomer();
                        if (result > 0)
                        {
                            MessageBox.Show("Customer has created successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.nullInputFied();
                            this.Close();
                        }
                    }
                }
            }
        }
        private void loadKitchen(string search = null)
        {
            kitchen = new Kitchen();
            List <Tuple <string, string, string> > kitchenList = new List <Tuple <string, string, string> >();

            if (search != null && Encrption.trim(search).Length > 0)
            {
                kitchenList = kitchen.getKitchens(kitchen.searchKitchen(search));
            }
            else
            {
                kitchenList = kitchen.getKitchens();
            }
            dgv_kitchen.Rows.Clear();
            int sno = 0;

            foreach (var tuple in kitchenList)
            {
                dgv_kitchen.Rows.Add(new object[] { ++sno, tuple.Item1, tuple.Item2, tuple.Item3 });
            }
        }
Example #14
0
 private void CheckEnterKeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)Keys.Return)
     {
         string username = Encrption.trim(txt_username.Text.ToString());
         string password = Encrption.trim(txt_password.Text.ToString());
         if (validateInput())
         {
             DataTable data = login.Login_action(username, password);
             if (data.Rows.Count > 0)
             {
                 if (Login.user_status.Equals("1"))
                 {
                     MainPanel mainPanel = new MainPanel();
                     mainPanel.Owner = this;
                     this.Hide();
                     mainPanel.Show();
                 }
                 else if (Login.user_status.Equals("2"))
                 {
                     MessageBox.Show("Your account has been de-active");
                 }
                 else if (Login.user_status.Equals("3"))
                 {
                     MessageBox.Show("Your account has been suspended");
                 }
                 else
                 {
                     MessageBox.Show("Your account has been terminated");
                 }
                 this.emptyInputField();
             }
             else
             {
                 MessageBox.Show("Invalid login id or password", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 this.emptyInputField();
             }
         }
     }
 }
        private void btn_search_Click(object sender, EventArgs e)
        {
            Customer customer = new Customer();

            if (txt_search.Text.ToString().Length > 0)
            {
                DataTable dataTable = customer.searchCustomer(Encrption.trim(txt_search.Text.ToString()), cb_search.SelectedItem.ToString());
                if (dataTable.Rows.Count > 0)
                {
                    btn_clear.Show();
                    this.customerGridViewFormatting(dataTable);
                }
                else
                {
                    MessageBox.Show("No record(s) found", "Infomation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show(String.Format("Please enter keyword to search by {0}", cb_search.SelectedItem.ToString()), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txt_search.Focus();
                this.loadCustomer();
            }
        }
Example #16
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            if (this.validateInput())
            {
                string name        = Encrption.trim(txt_name.Text.ToString());
                string father_name = Encrption.trim(txt_fathername.Text.ToString());
                string email       = Encrption.trim(txt_email.Text.ToString());
                string mobile      = Encrption.trim(txt_mobile.Text.ToString());
                string nic         = Encrption.trim(txt_nic.Text.ToString());
                string address     = Encrption.trim(txt_address.Text.ToString());
                string user_role   = cb_role.SelectedValue.ToString();
                string user_status = cb_status.SelectedValue.ToString();
                string created_at  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                string updated_at  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                if (this.isEditEmployee == true)
                {
                    if (this.filePath.Equals("") && this.fileExt.Equals(""))
                    {
                        if (this.removeImage == true)
                        {
                            employee = new Employee(int.Parse(this.employeeId), name, father_name, address, email, mobile, nic, user_role, "", user_status, updated_at);
                        }
                        else
                        {
                            employee = new Employee(int.Parse(this.employeeId), name, father_name, address, email, mobile, nic, user_role, this.previousImage, user_status, updated_at);
                        }
                        if (employee.updateEmployee() > 0)
                        {
                            MessageBox.Show("Employee has updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                    }
                    else
                    {
                        string file = Guid.NewGuid() + "_" + this.employeeId + this.fileExt;
                        this.appPath = this.appPath + file;
                        File.Copy(this.filePath, this.appPath);
                        employee = new Employee(int.Parse(this.employeeId), name, father_name, address, email, mobile, nic, user_role, file, user_status, updated_at);
                        if (employee.updateEmployee() > 0)
                        {
                            MessageBox.Show("Employee has updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                    }
                }
                else
                {
                    employee = new Employee(name, father_name, address, email, mobile, nic, user_role, "", user_status, created_at, updated_at);
                    int result = employee.addEmployee();
                    if (result > 0)
                    {
                        if (this.filePath.Equals("") && this.fileExt.Equals(""))
                        {
                            MessageBox.Show("Employee has inserted successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.nullInputFied();
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                        else
                        {
                            string employeeId = employee.getLastInsertedItemId();
                            string file       = Guid.NewGuid() + "_" + employeeId + this.fileExt;
                            this.appPath = this.appPath + file;
                            File.Copy(this.filePath, this.appPath);

                            employee = null;
                            employee = new Employee(employeeId, file);
                            int check = employee.updateItemImage();
                            if (check > 0)
                            {
                                MessageBox.Show("Employee has inserted successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.nullInputFied();
                                this.DialogResult = DialogResult.OK;
                                this.Close();
                            }
                        }
                    }
                }
            }
        }
Example #17
0
        private void EnterKeyPressEventOccure(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Return)
            {
                if (this.validateInput())
                {
                    string name        = Encrption.trim(txt_name.Text.ToString());
                    string father_name = Encrption.trim(txt_fathername.Text.ToString());
                    string email       = Encrption.trim(txt_email.Text.ToString());
                    string mobile      = Encrption.trim(txt_mobile.Text.ToString());
                    string nic         = Encrption.trim(txt_nic.Text.ToString());
                    string address     = Encrption.trim(txt_address.Text.ToString());
                    string user_role   = cb_role.SelectedValue.ToString();
                    string user_status = cb_status.SelectedValue.ToString();
                    string created_at  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    string updated_at  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");


                    if (this.isEditEmployee == true)
                    {
                        if (this.filePath.Equals("") && this.fileExt.Equals(""))
                        {
                            if (this.removeImage == true)
                            {
                                employee = new Employee(int.Parse(this.employeeId), name, father_name, address, email, mobile, nic, user_role, "", user_status, updated_at);
                            }
                            else
                            {
                                employee = new Employee(int.Parse(this.employeeId), name, father_name, address, email, mobile, nic, user_role, this.previousImage, user_status, updated_at);
                            }
                            if (employee.updateEmployee() > 0)
                            {
                                MessageBox.Show("Record has been updated");
                                this.Close();
                            }
                        }
                        else
                        {
                            string file = Guid.NewGuid() + "_" + this.employeeId + this.fileExt;
                            this.appPath = this.appPath + file;
                            File.Copy(this.filePath, this.appPath);
                            employee = new Employee(int.Parse(this.employeeId), name, father_name, address, email, mobile, nic, user_role, file, user_status, updated_at);
                            if (employee.updateEmployee() > 0)
                            {
                                MessageBox.Show("Record has been updated");
                                this.Close();
                            }
                        }
                    }
                    else
                    {
                        employee = new Employee(name, father_name, address, email, mobile, nic, user_role, "", user_status, created_at, updated_at);
                        int result = employee.addEmployee();
                        if (result > 0)
                        {
                            if (this.filePath.Equals("") && this.fileExt.Equals(""))
                            {
                                MessageBox.Show(String.Format("{0} Record has been inserted.", result));
                                this.nullInputFied();
                                this.Close();
                            }
                            else
                            {
                                string employeeId = employee.getLastInsertedItemId();
                                string file       = Guid.NewGuid() + "_" + employeeId + this.fileExt;
                                this.appPath = this.appPath + file;
                                File.Copy(this.filePath, this.appPath);

                                employee = null;
                                employee = new Employee(employeeId, file);
                                int check = employee.updateItemImage();
                                if (check > 0)
                                {
                                    MessageBox.Show("Record has been inserted");
                                    this.nullInputFied();
                                    this.Close();
                                }
                            }
                        }
                    }
                }
            }
        }
        private void btn_add_Click(object sender, EventArgs e)
        {
            if (this.validateInput())
            {
                string name           = Encrption.trim(txt_name.Text.ToString());
                string categoryId     = cb_category.SelectedValue.ToString();
                string desc           = Encrption.trim(txt_desc.Text.ToString());
                string sale_price     = Encrption.trim(txt_saleprice.Text.ToString());
                string purchase_price = Encrption.trim(txt_purchase.Text.ToString());
                string discount       = Encrption.trim(txt_discount.Text.ToString());
                string apply_discount = "0";

                if (chk_ad.Checked == true)
                {
                    apply_discount = "1";
                }
                string apply_tax = "0";
                if (chk_at.Checked == true)
                {
                    apply_tax = "1";
                }
                string is_kitchen = "0";
                if (chk_ktch.Checked == true)
                {
                    is_kitchen = "1";
                }

                string created_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                string updated_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                if (isEditItem == true)
                {
                    try
                    {
                        string file;
                        if (this.filePath.Equals(""))
                        {
                            file  = this.previousImage;
                            items = new Items(this.itemId, categoryId, name, desc, sale_price, purchase_price, discount, apply_discount, apply_tax, is_kitchen, file, created_at, updated_at);
                            int result = items.updateItem();
                            if (result > 0)
                            {
                                MessageBox.Show("Item has updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.DialogResult = DialogResult.OK;
                                this.Close();
                            }
                        }
                        else
                        {
                            file  = Guid.NewGuid() + "_" + this.itemId + this.fileExt;
                            items = new Items(this.itemId, categoryId, name, desc, sale_price, purchase_price, discount, apply_discount, apply_tax, is_kitchen, file, created_at, updated_at);
                            int result = items.updateItem();
                            if (result > 0)
                            {
                                MessageBox.Show("Item has updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                string checkFilePath = this.appPath + file;
                                File.Copy(this.filePath, checkFilePath, true);
                                this.DialogResult = DialogResult.OK;
                                this.Close();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    string imagePath = "";
                    items = new Items(categoryId, name, desc, sale_price, purchase_price, discount, apply_discount, apply_tax, is_kitchen, imagePath, created_at, updated_at);
                    int result = items.addItem();
                    if (result > 0)
                    {
                        if (this.filePath.Equals("") && this.fileExt.Equals(""))
                        {
                            MessageBox.Show("Item has created successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.DialogResult = DialogResult.OK;
                            this.nullInputFied();
                            this.Close();
                        }
                        else
                        {
                            string itemId = items.getLastInsertedItemId();
                            string file   = Guid.NewGuid() + "_" + itemId + this.fileExt;
                            this.appPath = this.appPath + file;
                            File.Copy(this.filePath, this.appPath);

                            items = null;
                            items = new Items(itemId, file);
                            int check = items.updateItemImage();
                            if (check > 0)
                            {
                                MessageBox.Show("Item has created successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.DialogResult = DialogResult.OK;
                                this.nullInputFied();
                                this.Close();
                            }
                        }
                    }
                }
            }
        }
 private void SearchPressEnterEventOccure(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (Char)Keys.Return)
     {
         Employee employee = new Employee();
         if (cb_search.SelectedItem.ToString().Equals("Name"))
         {
             if (txt_search.Text.ToString().Length > 0)
             {
                 DataTable data = employee.searchEmployee(Encrption.trim(txt_search.Text.ToString()), cb_search.SelectedItem.ToString());
                 if (data.Rows.Count > 0)
                 {
                     btn_clear.Show();
                     this.employeeGridViewFormatting(data);
                 }
                 else
                 {
                     MessageBox.Show("No record(s) found", "Infomation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             else
             {
                 MessageBox.Show(String.Format("Please enter keyword to search by {0}", cb_search.SelectedItem.ToString()), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txt_search.Focus();
                 this.loadEmployee();
             }
         }
         else if (cb_search.SelectedItem.ToString().Equals("Role"))
         {
             if (txt_search.Text.ToString().Length > 0)
             {
                 DataTable data = employee.searchEmployee(Encrption.trim(txt_search.Text.ToString()), cb_search.SelectedItem.ToString());
                 if (data.Rows.Count > 0)
                 {
                     btn_clear.Show();
                     this.employeeGridViewFormatting(data);
                 }
                 else
                 {
                     MessageBox.Show("No record(s) found", "Infomation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             else
             {
                 MessageBox.Show(String.Format("Please enter keyword to search by {0}", cb_search.SelectedItem.ToString()), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txt_search.Focus();
                 this.loadEmployee();
             }
         }
         else if (cb_search.SelectedItem.ToString().Equals("Mobile"))
         {
             if (txt_search.Text.ToString().Length > 0)
             {
                 DataTable data = employee.searchEmployee(Encrption.trim(txt_search.Text.ToString()), cb_search.SelectedItem.ToString());
                 if (data.Rows.Count > 0)
                 {
                     btn_clear.Show();
                     this.employeeGridViewFormatting(data);
                 }
                 else
                 {
                     MessageBox.Show("No record(s) found", "Infomation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             else
             {
                 MessageBox.Show(String.Format("Please enter keyword to search by {0}", cb_search.SelectedItem.ToString()), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txt_search.Focus();
                 this.loadEmployee();
             }
         }
         else if (cb_search.SelectedItem.ToString().Equals("Nic"))
         {
             if (txt_search.Text.ToString().Length > 0)
             {
                 DataTable data = employee.searchEmployee(Encrption.trim(txt_search.Text.ToString()), cb_search.SelectedItem.ToString());
                 if (data.Rows.Count > 0)
                 {
                     btn_clear.Show();
                     this.employeeGridViewFormatting(data);
                 }
                 else
                 {
                     MessageBox.Show("No record(s) found", "Infomation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             else
             {
                 MessageBox.Show(String.Format("Please enter keyword to search by {0}", cb_search.SelectedItem.ToString()), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txt_search.Focus();
                 this.loadEmployee();
             }
         }
         else
         {
             employee = null;
         }
     }
 }
        private void btn_update_Click(object sender, EventArgs e)
        {
            if (is_edit.Equals(true))
            {
                if (role.Equals("admin"))
                {
                    if (this.validateUser())
                    {
                        if (this.selectedUserId.Equals(Login.user_id))
                        {
                            if (this.verifiedUser == true)
                            {
                                if (txt_newPassword.Text.ToString().Length > 0)
                                {
                                    if (txt_newPassword.Text.ToString().Length >= 6 && txt_newPassword.Text.ToString().Length <= 20)
                                    {
                                        // Admin update operation
                                        string name        = Encrption.trim(txt_name.Text.ToString());
                                        string username    = Encrption.trim(txt_username.Text.ToString());
                                        string email       = Encrption.trim(txt_email.Text.ToString());
                                        string user_role   = cb_userRole.SelectedValue.ToString();
                                        string user_status = cb_userStatus.SelectedValue.ToString();
                                        string password    = Encrption.trim(txt_newPassword.Text.ToString());
                                        string created_at  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                                        users = new Users(Login.user_id, name, username, email, password, user_role, user_status, created_at);
                                        if (users.updateUser() > 0)
                                        {
                                            MessageBox.Show("User has updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            this.DialogResult = DialogResult.OK;
                                            this.Close();
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Password must be in between 6 to 20 character");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Please enter new password");
                                }
                            }
                            else
                            {
                                MessageBox.Show("Please enter password to verify");
                            }
                        }
                        else
                        {
                            if (login_id == txt_username.Text.ToString())
                            {
                                // Other update operation
                                string name        = Encrption.trim(txt_name.Text.ToString());
                                string username    = Encrption.trim(txt_username.Text.ToString());
                                string email       = Encrption.trim(txt_email.Text.ToString());
                                string user_role   = cb_userRole.SelectedValue.ToString();
                                string user_status = cb_userStatus.SelectedValue.ToString();
                                string password    = Encrption.trim(txt_password.Text.ToString());
                                string created_at  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                                users = new Users(this.selectedUserId, name, username, email, password, user_role, user_status, created_at);
                                if (users.updateUser() > 0)
                                {
                                    MessageBox.Show("User has updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    this.DialogResult = DialogResult.OK;
                                    this.Close();
                                }
                            }
                            else
                            {
                                users = new Users();
                                if (users.is_LoginIdAlreadyExist(txt_username.Text.ToString()))
                                {
                                    MessageBox.Show("Login id already taken", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                else
                                {
                                    // Other update operation
                                    string name        = Encrption.trim(txt_name.Text.ToString());
                                    string username    = Encrption.trim(txt_username.Text.ToString());
                                    string email       = Encrption.trim(txt_email.Text.ToString());
                                    string user_role   = cb_userRole.SelectedValue.ToString();
                                    string user_status = cb_userStatus.SelectedValue.ToString();
                                    string password    = Encrption.trim(txt_password.Text.ToString());
                                    string created_at  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                                    users = new Users(this.selectedUserId, name, username, email, password, user_role, user_status, created_at);
                                    if (users.updateUser() > 0)
                                    {
                                        MessageBox.Show("User has updated successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        this.Close();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (this.validateUser().Equals(true))
                {
                    users = new Users();
                    if (users.is_LoginIdAlreadyExist(txt_username.Text.ToString()))
                    {
                        MessageBox.Show("The Login Id is already in use", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        string name       = Encrption.trim(txt_name.Text.ToString());
                        string username   = Encrption.trim(txt_username.Text.ToString());
                        string email      = Encrption.trim(txt_email.Text.ToString());
                        string user_role  = cb_userRole.SelectedValue.ToString();
                        string status     = cb_userStatus.SelectedValue.ToString();
                        string password   = Encrption.trim(txt_password.Text.ToString());
                        string created_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        users = null;
                        users = new Users(0, name, username, email, password, user_role, status, created_at);
                        int result = users.addUser();
                        if (result > 0)
                        {
                            MessageBox.Show("The user has created successfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.nullInputField();
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                        else
                        {
                            this.nullInputField();
                        }
                    }
                }
            }
        }