Ejemplo n.º 1
0
        public HttpResponseMessage DeleteStaffType(StaffTypeModel sModel)
        {
            HttpResponseMessage   result;
            List <StaffTypeModel> datalist;

            try
            {
                if (this.ModelState.IsValid == true)
                {
                    datalist = service.DeleteStaffType(sModel);
                    if (datalist != null)
                    {
                        result = Request.CreateResponse(HttpStatusCode.OK, datalist);
                    }
                    else
                    {
                        string message = "Error while deleting StaffType data";
                        result = Request.CreateResponse(HttpStatusCode.Forbidden, message);
                    }
                }
                else
                {
                    result = Request.CreateResponse(HttpStatusCode.BadRequest, this.ModelState);
                }
            }
            catch (Exception ex)
            {
                result = Request.CreateResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message);
            }
            return(result);
        }
Ejemplo n.º 2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     _StaffTypeModelNow = null;
     _IStatusForm       = 1;
     _setStatusForm();
     txtID.Focus();
 }
Ejemplo n.º 3
0
        public bool addNewStaffType(StaffTypeModel staffType)
        {
            try
            {
                _Context.StaffTypeModels.Add(staffType);
                DecentralizeModel staff = new DecentralizeModel();
                foreach (FormModel x in _Context.FormModels)
                {
                    staff.StrStaffTypeID = staffType.StrStaffTypeID;
                    staff.BView          = true;
                    staff.BAdd           = false;
                    staff.BDelete        = false;
                    staff.BDelete        = false;
                    staff.BFullFuncion   = false;
                    staff.BAccess        = false;
                    staff.StrFormID      = x.StrFormID;
                    _Context.DecentralizeModels.Add(staff);
                }

                return(_Context.SaveChanges() != 0);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
 private void _getData()
 {
     if (_StaffTypeModelNow == null)
     {
         _StaffTypeModelNow = new StaffTypeModel();
     }
     _StaffTypeModelNow.StrStaffTypeID   = txtID.Text;
     _StaffTypeModelNow.StrStaffTypeName = txtName.Text;
 }
Ejemplo n.º 5
0
        //public bool addNewStaffType(StaffTypeModel staffType)
        //{
        //    try
        //    {

        //        _Context.StaffTypeModels.Add(staffType);
        //        DecentralizeModel staff = new DecentralizeModel();
        //        foreach (FormModel x in _Context.FormModels )
        //        {
        //            staff.StrStaffTypeID = staffType.StrStaffTypeID;
        //            staff.BView = true;
        //            staff.BAdd = false;
        //            staff.BDelete = false;
        //            staff.BDelete = false;
        //            staff.BFullFuncion = false;
        //            staff.BAccess = false;
        //            staff.StrFormID = x.StrFormID;
        //            _Context.DecentralizeModels.Add(staff);
        //        }

        //        return (_Context.SaveChanges() != 0);
        //    }
        //    catch
        //    {
        //        return false;
        //    }

        //}

        public bool addStaffTypeNew(StaffTypeModel staffType)
        {
            try
            {
                _Context.StaffTypeModels.Add(staffType);
                return(_Context.SaveChanges() != 0);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        private void gvStaffTypeList_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
        {
            if (gvStaffTypeList.SelectedRowsCount > 0)
            {
                _StaffTypeModelNow = (StaffTypeModel)gvStaffTypeList.GetRow(gvStaffTypeList.FocusedRowHandle);
            }
            else
            {
                _StaffTypeModelNow = null;
            }

            _loadData();
            _IStatusForm = 0;
            _setStatusForm();
        }
Ejemplo n.º 7
0
        public bool deleteCurrentStaffType(StaffTypeModel staffType)
        {
            try
            {
                var StaffTypeToDelete = _Context.StaffTypeModels.SingleOrDefault
                                            (x => x.StrStaffTypeID == staffType.StrStaffTypeID);
                _Context.StaffTypeModels.Remove(StaffTypeToDelete);

                return(_Context.SaveChanges() != 0);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
        public bool updateCurrentStaffType(StaffTypeModel staffType)
        {
            try
            {
                var StaffTypeToUpdate = _Context.StaffTypeModels.SingleOrDefault
                                            (x => x.StrStaffTypeID == staffType.StrStaffTypeID);
                if (StaffTypeToUpdate != null)
                {
                    StaffTypeToUpdate.StrStaffTypeName = staffType.StrStaffTypeName;
                    return(_Context.SaveChanges() != 0);
                }

                return(false);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 9
0
        private bool adddDecen(StaffTypeModel type)
        {
            BindingList <FormModel> _lstFrm = new BindingList <FormModel>();

            _lstFrm = _Form.loadForm();
            for (int i = 0; i < _lstFrm.Count; i++)
            {
                DecentralizeModel decens = new DecentralizeModel();
                decens.StrStaffTypeID = type.StrStaffTypeID;
                decens.StrFormID      = _lstFrm[i].StrFormID;
                if (_lstFrm[i].StrFormID != "frmDecentralization")
                {
                    decens.BView = true;
                }
                if (!_Decen.addNewDecentralize(decens))
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 10
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (_StaffTypeModelNow != null)
     {
         if (_StaffType.deleteCurrentStaffType(_StaffTypeModelNow))
         {
             _lstLoadListStaffType();
             DevExpress.XtraEditors.XtraMessageBox.Show("Xóa Thành Công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             if (_lstStaffType.Count == 0)
             {
                 _StaffTypeModelNow = null;
                 _IStatusForm       = 0;
                 _setStatusForm();
             }
         }
         else
         {
             DevExpress.XtraEditors.XtraMessageBox.Show("Xóa Thất Bại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }