public BDPhysicianSalary PhysicianSalarySaveChange(BDPhysicianSalary _bDPhysicianSalary)
        {
            try
            {
                // BDPhysicianSalary operation add & edit

                var dbPhysicianSalary = _contextDatabase.BDPhysicianSalaries.SingleOrDefault(s => s.PhysicianPriceID == _bDPhysicianSalary.PhysicianPriceID);
                if (dbPhysicianSalary != null)
                {
                    // Update BDPhysicianSalary
                    _contextDatabase.Entry(dbPhysicianSalary).CurrentValues.SetValues(_bDPhysicianSalary);
                    _contextDatabase.BDPhysicianSalaries.Attach(dbPhysicianSalary);
                    _contextDatabase.SaveChanges();
                    return dbPhysicianSalary;
                }
                else
                {
                    // Insert BDPhysicianSalary into the database 
                    _contextDatabase.BDPhysicianSalaries.Add(_bDPhysicianSalary);
                    _contextDatabase.SaveChanges();
                    return _bDPhysicianSalary;
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return null;
        }
 public bool ValidatePhysicianSalary(BDPhysicianSalary _bDPhysicianSalary)
 {
     try
     {
         var query = _contextDatabase.BDPhysicianSalaries.AsQueryable();
         if (_bDPhysicianSalary.PhysicianPriceID != null && _bDPhysicianSalary.PhysicianPriceID > 0)
             query = query.Where(a => a.PhysicianPriceID != _bDPhysicianSalary.PhysicianPriceID).AsQueryable();
         query = query.Where(a => a.PhysicianID == _bDPhysicianSalary.PhysicianID).AsQueryable();
         query = query.Where(a => (a.FromDate >= _bDPhysicianSalary.ToDate && a.ToDate <= _bDPhysicianSalary.ToDate) || (a.FromDate <= _bDPhysicianSalary.FromDate && a.ToDate >= _bDPhysicianSalary.FromDate)).AsQueryable();
         return !query.Any();
     }
     catch (Exception ex)
     {
         throw;
     }
     return false;
 }
 /// <summary>
 /// ma object to control in UI form
 /// </summary>
 /// <param name="newObj"></param>
 private void ObjectToUI(BDPhysicianSalary newObj)
 {
     txtId.Text = newObj.PhysicianPriceID.ToString();
     dateTimePicker1.Value = newObj.FromDate;
     dateTimePicker2.Value = newObj.ToDate;
     numericUpDown2.Value = newObj.PhysicianSalary;
     cbx_PhysicianName.SelectedValue = newObj.PhysicianID;
 }
 /// <summary>
 /// Get data from UI to create new Object
 /// </summary>
 /// <returns></returns>
 private BDPhysicianSalary ObjectFromUI()
 {
     BDPhysicianSalary newObj = new BDPhysicianSalary();
     newObj.PhysicianPriceID = int.Parse(txtId.Text);
     newObj.FromDate = dateTimePicker1.Value;
     newObj.ToDate = dateTimePicker2.Value;
     newObj.PhysicianSalary = numericUpDown2.Value;
     newObj.PhysicianID = int.Parse(cbx_PhysicianName.SelectedValue.ToString());
     return newObj;
 }