コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Employee employee           = CreateEmployeeByForm();
            var      employeeDataMapper = new EmployeeDataMapper();

            if (_employeeId == 0)
            {
                employeeDataMapper.Insert(employee);
            }
            else
            {
                employee.Id = _employeeId;
                employeeDataMapper.Update(employee);
            }
            Dispose();
        }
コード例 #2
0
        public bool UpdateBLL(Employee item)
        {
            int  affectedRows = 0;
            bool result       = false;

            if (item != null)
            {
                if (string.IsNullOrWhiteSpace(item.Email))  //Email
                {
                    throw new Exception("Email boş geçilemez |Employee #Update +002");
                }
                if (string.IsNullOrWhiteSpace(item.FirstName))
                {
                    throw new Exception("isim alanı boş geçilemez |Employe #Update +002");
                }
                if (string.IsNullOrWhiteSpace(item.LastName))
                {
                    throw new Exception("Soyisim Boş geçilemez |Employee #Update +002");
                }
                if (item.Gender == null)
                {
                    throw new Exception("Gender Boş geçilemez |Employee #Update +002");
                }
                if (string.IsNullOrWhiteSpace(item.SocialNumber))
                {
                    throw new Exception("tc.no boş geçilemez |Employee #Update +002");
                }
                if (item.StartWorkDate == null)
                {
                    throw new Exception("DateTime Boş geçilemez |Employee #Update +002");
                }
                if (item.FinishWorkDate < item.StartWorkDate)
                {
                    throw new Exception("Bitiş degeri başlangıç degerinden küçük olamaz |Employee #Update +002 ");
                }
                if (item.CreatedEmployeeID <= 0 || item.CreatedEmployeeID == null)
                {
                    throw new Exception("Bir employee Id verilmelidir |Employee #Update +002");
                }
                if (item.RoleID <= 0 || item.RoleID == null)
                {
                    throw new Exception("Role Id Boş geçilemez |Employee #Update +002");
                }
                if (string.IsNullOrWhiteSpace(item.Telephone))
                {
                    throw new Exception("Telefona Boşgeçilemez  |Employee #Update +002 ");
                }
                if (item.IsAvaible == null)
                {
                    throw new Exception("Çalışma durumu  |Employee #Update +002");
                }

                affectedRows = _employeeMapper.Update(item);  //degerleri Insert et

                if (affectedRows > 0)
                {
                    result = affectedRows > 0;
                }
                else
                {
                    throw new Exception("Güncelleme Başarısız |Employee #Update +002 ");
                }
            }



            return(result); // bunu kontrol et
        }