コード例 #1
0
        public void ExecuteCommand(Employee employeeToDelete)
        {
            dapperHub.BeginTransaction();

            dapperHub.Delete(employeeToDelete);

            dapperHub.CommitTransaction();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: AAnde/EntityCodeFirst
 private static void AddEmployee()
 {
     Employee emp = new Employee()
     {
         Name = "ashok",
         Salary = 25000
     };
     operations.AddEmp(emp);
 }
コード例 #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (validator1.Validate())
            {
                if (employee != null && employee.Id > 0)//edit
                {
                    employee.Address = txtAddress.Text;
                    employee.Description = txtDescription.Text;
                    employee.Email = txtEmail.Text;
                    employee.FullName = txtFullName.Text;
                    employee.MobilePhone = txtMobilePhone.Text;
                    employee.NickName = txtNickName.Text;
                    employee.Code = txtEmployeeCode.Text;
                    employee.Type = cbType.SelectedValue != null ? (short)cbType.SelectedValue : (short)0;

                    EmployeeService employeeService = new EmployeeService();
                    bool result = employeeService.UpdateEmployee(employee);
                    if (result)
                    {
                        MessageBox.Show("Thông tin nhân viên đã được cập nhật vào hệ thống");
                        ((EmployeeList)this.CallFromUserControll).loadEmployeeList();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else//add new
                {
                    employee = new Employee
                    {
                        Address = txtAddress.Text,
                        Description = txtDescription.Text,
                        Email = txtEmail.Text,
                        FullName = txtFullName.Text,
                        MobilePhone = txtMobilePhone.Text,
                        NickName = txtNickName.Text,
                        Code = txtEmployeeCode.Text,
                        Type = cbType.SelectedValue != null ? (short)cbType.SelectedValue : (short)0
                    };
                    EmployeeService employeeService = new EmployeeService();
                    bool result = employeeService.AddEmployee(employee);
                    if (result)
                    {
                        MessageBox.Show("Nhân viên đã được thêm mới vào hệ thống");
                        ((EmployeeList)this.CallFromUserControll).loadEmployeeList();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
コード例 #4
0
        public void ExecuteQuery(Employee newEmployee, IEnumerable<Dependents> dependents)
        {
            dapperHub.BeginTransaction();

            var employeeID = dapperHub.Insert(newEmployee);

            AddDependents(dependents, employeeID);

            dapperHub.CommitTransaction();
        }
コード例 #5
0
 public void AddEmployee(DAL.Employee e, tblSalary s)
 {
     using (OriginatorEntities db = new OriginatorEntities())
     {
         db.Employees.Add(e);
         db.SaveChanges();
         s.EmployeeId = e.ID;
         db.tblSalaries.Add(s);
         db.SaveChanges();
     }
 }
コード例 #6
0
 public DAL.Employee GetMapper(Employeedto et)
 {
     DAL.Employee emply = new DAL.Employee();
     emply.Employeid = et.emp_id;
     emply.Firstname = et.First_name;
     emply.Lastname  = et.Last_name;
     emply.Phoneno   = et.Phone_no;
     emply.Gender    = et.gender;
     emply.State     = et.State;
     emply.Country   = et.Country;
     return(emply);
 }
コード例 #7
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridViewEmployees.SelectedRows.Count != 0)
                {
                    DAL.Employee emp = (DAL.Employee)bindingSourceEmployees.Current;

                    var _EmployeesWithPayslipDetquery = from br in rep.GetEmployeesWithPayslipDet()
                                                        select br;
                    List <DAL.Employee> _EmployeesWithPayslipDet = _EmployeesWithPayslipDetquery.ToList();

                    var _EmployeesWithPayslipDet_Tempquery = from br in rep.GetEmployeesWithPayslipDet_Temp()
                                                             select br;
                    List <DAL.Employee> _EmployeesWithPayslipDet_Temp = _EmployeesWithPayslipDet_Tempquery.ToList();

                    var _EmployeesWithPayslipMasterquery = from br in rep.GetEmployeesWithPayslipMaster()
                                                           select br;
                    List <DAL.Employee> _EmployeesWithPayslipMaster = _EmployeesWithPayslipMasterquery.ToList();

                    var _EmployeesWithPayslipMaster_Tempquery = from br in rep.GetEmployeesWithPayslipMaster_Temp()
                                                                select br;
                    List <DAL.Employee> _EmployeesWithPayslipMaster_Temp = _EmployeesWithPayslipMaster_Tempquery.ToList();

                    if (_EmployeesWithPayslipDet.Count > 0)
                    {
                        MessageBox.Show("There is a Processed Payroll Associated with this Employee!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (_EmployeesWithPayslipDet_Temp.Count > 0)
                    {
                        MessageBox.Show("There is a Processed Payroll Associated with this Employee!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (_EmployeesWithPayslipMaster.Count > 0)
                    {
                        MessageBox.Show("There is a Processed Payroll Associated with this Employee!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (_EmployeesWithPayslipMaster_Temp.Count > 0)
                    {
                        MessageBox.Show("There is a Processed Payroll Associated with this Employee!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    if (DialogResult.Yes == MessageBox.Show("Are you sure you want to delete employee\n" + emp.Surname.ToString().Trim().ToUpper() + "  " + emp.OtherNames.ToString().Trim().ToUpper(), "Confirm Delete", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                    {
                        de.DeleteEmployee(emp.EmpNo);
                        RefreshGrid();
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowError(ex);
            }
        }
コード例 #8
0
 public int InsertEmployee (Employee employee)
 {
     demoDbContext context = new demoDbContext();
     context.employees.Add(new EmployeeEntity()
     {
         Id = employee.Id,
         Name = employee.Name
     });
     context.SaveChanges();
     
     return employee.Id;
 }
コード例 #9
0
        public NonCashBenefits(DAL.Employee emp, string Conn)
        {
            InitializeComponent();

            if (string.IsNullOrEmpty(Conn))
            {
                throw new ArgumentNullException("connection");
            }
            connection = Conn;

            de       = new DataEntry(connection);
            db       = new SBPayrollDBEntities(connection);
            rep      = new Repository(connection);
            employee = emp;
        }
コード例 #10
0
        public void InstantiateCallerRequested(XmlWriter localXmlWriter, string xmlFileName)
        {
            customer = null;
            item = null;
            salesHeader= null;
            salesItem = null;
            employee = null;

            XmlReader xmlReader = XmlReader.Create(xmlFileName);
            while (xmlReader.Read())
            {
                if (xmlReader.NodeType == XmlNodeType.Element
                    && xmlReader.Name == "Customer")
                {
                    customer = Activator.CreateInstance<Customer>();
                    break;
                }
                if (xmlReader.NodeType == XmlNodeType.Element
                    && xmlReader.Name == "Item")
                {
                    item = Activator.CreateInstance<Item>();
                    break;
                }
                if (xmlReader.NodeType == XmlNodeType.Element
                    && xmlReader.Name == "SalesHeader")
                {
                    salesHeader = Activator.CreateInstance<SalesHeader>();
                    break;
                }
                if (xmlReader.NodeType == XmlNodeType.Element
                    && xmlReader.Name == "SalesItem")
                {
                    salesItem = Activator.CreateInstance<SalesItem>();
                    break;
                }
                if (xmlReader.NodeType == XmlNodeType.Element
                    && xmlReader.Name == "Employee")
                {
                    employee = Activator.CreateInstance<Employee>();
                    break;
                }
                //throw Exception("No Caller Requested found in XML");

            }
            xmlReader.Close();
        }
コード例 #11
0
 void LoadEmployees()
 {
     EmployeeService employeeService = new EmployeeService();
     employees = employeeService.GetEmployees();
     Employee e = new Employee
     {
         Id = 0,
         FullName = "Tất cả"
     };
     employees.Add(e);
     employees = employees.OrderBy(el => el.Id).ToList();
     if (employees != null)
     {
         cbmEmployees.DataSource = employees;
         cbmEmployees.DisplayMember = "FullName";
         cbmEmployees.ValueMember = "Id";
     }
 }
コード例 #12
0
        private void dataGridViewEmployees_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (dataGridViewEmployees.SelectedRows.Count != 0)
                {
                    DAL.Employee emp = (DAL.Employee)bindingSourceEmployees.Current;

                    Forms.EditEmployee f = new EditEmployee(emp, _user, connection);
                    f.Text  = emp.Surname.ToString().Trim().ToUpper() + "     " + emp.OtherNames.ToString().Trim().ToUpper();
                    f.Owner = this;
                    f.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                Utils.ShowError(ex);
            }
        }
コード例 #13
0
        public void loadDataForEditEmployee(int employeeId)
        {
            this.Text = "Chỉnh sửa thông tin nhân viên";
            this.btnSave.Text = "Cập nhật";

            EmployeeService employeeService = new EmployeeService();

            employee = employeeService.GetEmployee(employeeId);
            if (employee != null)
            {
                txtAddress.Text = employee.Address ;
                txtDescription.Text = employee.Description;
                txtEmail.Text = employee.Email;
                txtFullName.Text = employee.FullName;
                txtMobilePhone.Text = employee.MobilePhone;
                txtNickName.Text = employee.NickName ;
                txtEmployeeCode.Text = employee.Code;
                cbType.SelectedIndex = (int)employee.Type;
            }
        }
コード例 #14
0
        private void formPucrchaseNew_Load(object sender, EventArgs e)
        {
            DAL.Ledger ledger = new Ledger();
            comboBoxLedger.DataSource    = ledger.Select().Tables[0];
            comboBoxLedger.DisplayMember = "name";
            comboBoxLedger.ValueMember   = "id";
            comboBoxLedger.SelectedValue = -1;

            DAL.Employee employee = new DAL.Employee();
            comboBoxEmployee.DataSource    = employee.Select().Tables[0];
            comboBoxEmployee.DisplayMember = "name";
            comboBoxEmployee.ValueMember   = "id";
            comboBoxEmployee.SelectedValue = -1;

            DAL.Product product = new Product();
            ColProduct.DataSource    = product.Select().Tables[0];
            ColProduct.DisplayMember = "name";
            ColProduct.ValueMember   = "id";

            this.MaximumSize = this.Size;
            this.MinimumSize = this.Size;
        }
コード例 #15
0
        public void UpdateEmployee(long EmployeeId, DAL.Employee e, tblSalary s)
        {
            using (OriginatorEntities db = new OriginatorEntities())
            {
                DAL.Employee found = db.Employees.Find(EmployeeId);
                if (!string.IsNullOrWhiteSpace(e.FirstName))
                {
                    found.FirstName = e.FirstName;
                }
                if (!string.IsNullOrWhiteSpace(e.LastName))
                {
                    found.LastName = e.LastName;
                }
                if (!string.IsNullOrWhiteSpace(e.Designation))
                {
                    found.Designation = e.Designation;
                }
                if (!string.IsNullOrWhiteSpace(e.ImageUrl))
                {
                    found.ImageUrl = e.ImageUrl;
                }
                if (e.ModifiedBy != null && e.ModifiedBy > 0)
                {
                    found.ModifiedBy = e.ModifiedBy;
                }
                if (!string.IsNullOrWhiteSpace(e.ModifiedDate.ToString()))
                {
                    found.ModifiedDate = e.ModifiedDate;
                }

                // Get Latest Salary
                // If Latest salary is equal to parameter wali salary then then you dont want to change anything
                // other wise add new entry to salary table
                db.SaveChanges();
            }
        }
コード例 #16
0
 /// <summary>
 /// Create a new Employee object.
 /// </summary>
 /// <param name="employeeId">Initial value of the EmployeeId property.</param>
 /// <param name="code">Initial value of the Code property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="middleName">Initial value of the MiddleName property.</param>
 /// <param name="type">Initial value of the Type property.</param>
 public static Employee CreateEmployee(global::System.Int32 employeeId, global::System.String code, global::System.String firstName, global::System.String lastName, global::System.String middleName, global::System.Int16 type)
 {
     Employee employee = new Employee();
     employee.EmployeeId = employeeId;
     employee.Code = code;
     employee.FirstName = firstName;
     employee.LastName = lastName;
     employee.MiddleName = middleName;
     employee.Type = type;
     return employee;
 }
コード例 #17
0
 // class constructor
 public EmployeeSelectEventArgs(DAL.Employee employee)
 {
     this._employee = employee;
 }
コード例 #18
0
ファイル: EmployeesDb.cs プロジェクト: aftabnabi/MilkCRMUI
 public void Insert(Employee cust)
 {
     db.Employees.Add(cust);
     Save();
 }
コード例 #19
0
 partial void DeleteEmployee(Employee instance);
コード例 #20
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Employees EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEmployees(Employee employee)
 {
     base.AddObject("Employees", employee);
 }
コード例 #21
0
 partial void InsertEmployee(Employee instance);
コード例 #22
0
 partial void UpdateEmployee(Employee instance);
コード例 #23
0
ファイル: EmployeesDb.cs プロジェクト: aftabnabi/MilkCRMUI
 public void Update(Employee cust)
 {
     db.Entry(cust).State = EntityState.Modified;
     Save();
 }
コード例 #24
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            if (IsEmployeeValid())
            {
                try
                {
                    DAL.Employee employee = new DAL.Employee();
                    if (!string.IsNullOrEmpty(txtEmpNo.Text))
                    {
                        employee.EmpNo = txtEmpNo.Text.Trim();
                    }
                    if (!string.IsNullOrEmpty(txtEmail.Text))
                    {
                        employee.Email = txtEmail.Text.Trim();
                    }
                    if (!string.IsNullOrEmpty(txtSurname.Text))
                    {
                        employee.Surname = Utils.ConvertFirstLetterToUpper(txtSurname.Text.Trim());
                    }
                    if (!string.IsNullOrEmpty(txtOtherNames.Text))
                    {
                        employee.OtherNames = Utils.ConvertFirstLetterToUpper(txtOtherNames.Text.Trim());
                    }
                    employee.DoB = dtpDOB.Value;
                    if (cbMaritalStatus.SelectedIndex != -1)
                    {
                        employee.MaritalStatus = cbMaritalStatus.SelectedValue.ToString();
                    }
                    if (cbGender.SelectedIndex != -1)
                    {
                        employee.Gender = cbGender.SelectedValue.ToString();
                    }
                    if (pbPhoto.ImageLocation != null)
                    {
                        employee.Photo = pbPhoto.ImageLocation.ToString().Trim();
                    }
                    employee.DoE = dtpDOE.Value;
                    if (cbBasicComputation.SelectedIndex != -1)
                    {
                        employee.BasicComputation = cbBasicComputation.SelectedValue.ToString();
                    }
                    decimal basicpay;
                    if (!string.IsNullOrEmpty(txtBasicPay.Text) && decimal.TryParse(txtBasicPay.Text, out basicpay))
                    {
                        employee.BasicPay = decimal.Parse(txtBasicPay.Text.Trim());
                    }
                    decimal personalrelief;
                    if (!string.IsNullOrEmpty(txtPersonalRelief.Text) && decimal.TryParse(txtPersonalRelief.Text, out personalrelief))
                    {
                        employee.PersonalRelief = decimal.Parse(txtPersonalRelief.Text.Trim());
                    }
                    decimal morgagerelief;
                    if (!string.IsNullOrEmpty(txtMortgageRelief.Text) && decimal.TryParse(txtMortgageRelief.Text, out morgagerelief))
                    {
                        employee.MortgageRelief = decimal.Parse(txtMortgageRelief.Text.Trim());
                    }
                    decimal insurancerelief;
                    if (!string.IsNullOrEmpty(txtInsuranceRelief.Text) && decimal.TryParse(txtInsuranceRelief.Text, out insurancerelief))
                    {
                        employee.InsuranceRelief = decimal.Parse(txtInsuranceRelief.Text.Trim());
                    }
                    if (!string.IsNullOrEmpty(txtNSSF.Text))
                    {
                        employee.NSSFNo = txtNSSF.Text.Trim();
                    }
                    if (!string.IsNullOrEmpty(txtNHIF.Text))
                    {
                        employee.NHIFNo = txtNHIF.Text.Trim();
                    }
                    if (!string.IsNullOrEmpty(txtIDNo.Text))
                    {
                        employee.IDNo = txtIDNo.Text.Trim();
                    }
                    if (!string.IsNullOrEmpty(txtPIN.Text))
                    {
                        employee.PINNo = txtPIN.Text.Trim();
                    }
                    if (cbDepartment.SelectedIndex != -1)
                    {
                        employee.DepartmentId = int.Parse(cbDepartment.SelectedValue.ToString());
                    }
                    if (cbEmployer.SelectedIndex != -1)
                    {
                        employee.EmployerId = int.Parse(cbEmployer.SelectedValue.ToString());
                    }
                    if (!string.IsNullOrEmpty(txtEmployeePaymentPoint.Text))
                    {
                        employee.PayPoint = txtEmployeePaymentPoint.Text.Trim();
                    }
                    if (cboEmployeeGroup.SelectedIndex != -1)
                    {
                        employee.EmpGroup = cboEmployeeGroup.SelectedValue.ToString();
                    }
                    if (cboEmpPayroll.SelectedIndex != -1)
                    {
                        employee.EmpPayroll = cboEmpPayroll.SelectedValue.ToString();
                    }
                    if (!string.IsNullOrEmpty(txtPrevEmployer.Text))
                    {
                        employee.PrevEmployer = txtPrevEmployer.Text.Trim();
                    }
                    employee.DateLeft = dtpDateLeft.Value;
                    if (cboModeofPayment.SelectedIndex != -1)
                    {
                        employee.PaymentMode = cboModeofPayment.SelectedValue.ToString();
                    }
                    switch (cboModeofPayment.SelectedValue.ToString())
                    {
                    case "M":
                        if (string.IsNullOrEmpty(txtTelephoneNo.Text))
                        {
                            txtTelephoneNo.Text  = "0";
                            employee.TelephoneNo = txtTelephoneNo.Text.Trim();
                        }
                        else
                        {
                            employee.TelephoneNo = txtTelephoneNo.Text.Trim();
                        }
                        break;

                    case "B":
                        if (string.IsNullOrEmpty(txtAccount.Text))
                        {
                            txtAccount.Text      = "0";
                            employee.BankAccount = txtAccount.Text.Trim();
                            employee.BankCode    = txtBankSortCode.Text.ToString();
                        }
                        else
                        {
                            employee.BankAccount = txtAccount.Text.Trim();
                            employee.BankCode    = txtBankSortCode.Text.ToString();
                        }
                        break;
                    }
                    employee.IsActive  = true; //on entry, all employees will be active. a System Administrator can change this
                    employee.IsDeleted = false;
                    employee.CreatedBy = _User;
                    employee.CreatedOn = DateTime.Now;
                    employee.SystemId  = "ws";

                    DAL.Employee returnedEmployee = rep.CreateEmployee(employee);

                    if (returnedEmployee != null)
                    {
                        //add defualt employee transactions
                        de.AddDefaultEmpTransactions(returnedEmployee.Id, returnedEmployee.EmpNo, returnedEmployee.BasicPay ?? 0, _User);
                        Employees f = (Employees)this.Owner;
                        f.RefreshGrid();
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    Utils.ShowError(ex);
                }
            }
        }
コード例 #25
0
ファイル: Program.cs プロジェクト: AAnde/EntityCodeFirst
 private static void UpdateEmployee()
 {
     Employee emp = new Employee()
     {
         Id = 2,
         Name = "ashok",
         Salary = 25000,
         DepartId = 1
     };
     operations.UpdateEmp(emp);
 }