Пример #1
0
        private void Empdet_Click(object sender, EventArgs e)
        {
            EmployeeMangementDetailsList em = EmployeeMangementDetailsList.getInstance();

            this.Hide();
            em.Show();
        }
Пример #2
0
        private void btnallEmployess_Click(object sender, EventArgs e)
        {
            EmployeeMangementDetailsList emplist = EmployeeMangementDetailsList.getInstance();

            emplist.Show();
            this.Hide();
        }
Пример #3
0
        private void btndeleteempCard_Click(object sender, EventArgs e)
        {
            String cardID = this.lblcardid.Text;

            EmployeeMangementDetailsList em = new EmployeeMangementDetailsList();

            em.deleteEmp(cardID);
        }
 public static EmployeeMangementDetailsList getInstance()
 {
     if (uniqueInstance == null)
     {
         uniqueInstance = new EmployeeMangementDetailsList();
     }
     return(uniqueInstance);
 }
Пример #5
0
        //save employee details database
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            if (validateFormDetails())
            {
                try
                {
                    //text boxes
                    employeeModel.employeeId    = txtempid.Text;
                    employeeModel.fname         = txtfname.Text;
                    employeeModel.lname         = txtlname.Text;
                    employeeModel.dob           = txtdob.Value;
                    employeeModel.contactno     = int.Parse(txtconatcno.Text);
                    employeeModel.nic           = txtnic.Text;
                    employeeModel.matrialstatus = txtmatrialststus.Text;
                    employeeModel.email         = txtemail.Text;
                    employeeModel.basicsalary   = Int32.Parse(txtbasicsal.Text);
                    employeeModel.gender        = cmbgender.Text;
                    employeeModel.nationality   = txtnationality.Text;
                    employeeModel.address       = txtaddress.Text;
                    employeeModel.designation   = empType;

                    if (empType == "driver")
                    {
                        //textboxes and combo box driver
                        driverModel.driverid  = txtempid.Text;
                        driverModel.licenceNo = Int32.Parse(txtlicenceno.Text);
                        driverModel.service   = cmbDriverSerivice.Text;
                        driverModel.type      = cmbdrivertype.Text;
                    }

                    if (empType == "cleaner")
                    {
                        //combo box cleaner
                        cleanerModel.ctype     = txtclenertype.Text;
                        cleanerModel.cleanerid = txtempid.Text;
                    }
                    if (empType == "receptionist")
                    {
                        //combo box receptions
                        receptionModel.receptionid = txtempid.Text;
                        receptionModel.language    = cmblanguage.Text;
                    }
                    if (empType == "manager")
                    {
                        //combo boc manager
                        ManagerModel.Managerid  = txtempid.Text;
                        ManagerModel.experience = cmbexperiecnce.Text;
                    }
                    if (empType == "headChef")
                    {
                        //combo box mheadchef
                        HeadchefModel.headchefid = txtempid.Text;
                        HeadchefModel.service    = txtservice.Text;
                    }

                    //imagee
                    employeeModel.image = Util.convertImageToBinary(picBoxEmp.Image);
                }
                //exception handling
                catch (NullReferenceException)
                {
                    MessageBox.Show("Please fill the text box and Image", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (FormatException)
                {
                    MessageBox.Show("please fill the integer number", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                using (DBEntities db = new DBEntities())
                {
                    if (status == "insert")
                    {
                        //adding the employee
                        db.Employees.Add(employeeModel);
                    }
                    else if (status == "update")
                    {
                        db.Entry(employeeModel).State = EntityState.Modified;
                    }

                    if (empType == "driver")
                    {
                        if (status == "insert")
                        {
                            //adding the driver
                            db.Drivers.Add(driverModel);
                            MessageBox.Show("Driver added Successfully!!!");
                        }
                        else if (status == "update")
                        {
                            //update the table
                            db.Entry(driverModel).State = EntityState.Modified;

                            MessageBox.Show("driver Updated Successfully");
                        }
                        clearTexts();
                        // db.SaveChanges();
                    }
                    else if (empType == "cleaner")
                    {
                        if (status == "insert")
                        {
                            //adding the cleaner
                            db.Cleaners.Add(cleanerModel);
                            MessageBox.Show("Cleaner added Successfully!!!");
                        }
                        else if (status == "update")
                        {
                            //update the table
                            db.Entry(cleanerModel).State = EntityState.Modified;

                            MessageBox.Show("driver Updated Successfully");
                        }
                        clearTexts();
                        //db.SaveChanges();
                    }
                    else if (empType == "receptionist")
                    {
                        if (status == "insert")
                        {
                            //adding the receptionist
                            db.Receptions.Add(receptionModel);
                            MessageBox.Show("receptionist added Successfully!!!");
                        }
                        else if (status == "update")
                        {
                            //update the table
                            db.Entry(receptionModel).State = EntityState.Modified;

                            MessageBox.Show("Reception Updated Successfully");
                        }
                        clearTexts();
                        // db.SaveChanges();
                    }
                    else if (empType == "manager")
                    {
                        if (status == "insert")
                        {
                            //adding the manager
                            db.Managers.Add(ManagerModel);
                            MessageBox.Show("Manager added Successfully!!!");
                        }
                        else if (status == "update")
                        {
                            //update the table
                            db.Entry(ManagerModel).State = EntityState.Modified;

                            MessageBox.Show("Reception Updated Successfully");
                        }

                        // db.SaveChanges();
                        clearTexts();
                    }
                    else if (empType == "headChef")
                    {
                        if (status == "insert")
                        {
                            //adding the headchef
                            db.HeadChefs.Add(HeadchefModel);
                            MessageBox.Show("Manager added Successfully!!!");
                        }
                        else if (status == "update")
                        {
                            //update the table
                            db.Entry(HeadchefModel).State = EntityState.Modified;

                            MessageBox.Show("Reception Updated Successfully");
                        }

                        //db.SaveChanges();
                        clearTexts();
                    }
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (DbUpdateException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    catch (DbEntityValidationException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                EmployeeMangementDetailsList em = EmployeeMangementDetailsList.getInstance();
                em.Show();
                this.Hide();
                em.clearempcardpanel();
                em.loadEmployees();
                Refresh();
            }
        }//end of save event==============================================================