Exemplo n.º 1
0
        private void gridViewStep_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                int Id = 0;
                int.TryParse(gridViewStep.GetRowCellValue(gridViewStep.FocusedRowHandle, "Id").ToString(), out Id);
                if (Id == 0 && string.IsNullOrEmpty(gridViewStep.GetRowCellValue(gridViewStep.FocusedRowHandle, "Index").ToString()))
                {
                    goto End;
                }
                else if (Id == 0 && string.IsNullOrEmpty(gridViewStep.GetRowCellValue(gridViewStep.FocusedRowHandle, "MajorId").ToString()))
                {
                    goto End;
                }

                if (Id != 0 && string.IsNullOrEmpty(gridViewStep.GetRowCellValue(gridViewStep.FocusedRowHandle, "Index").ToString()))
                {
                    MessageBox.Show("Vui lòng nhập số thứ tự ưu tiên.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (Id != 0 && string.IsNullOrEmpty(gridViewStep.GetRowCellValue(gridViewStep.FocusedRowHandle, "MajorId").ToString()))
                {
                    MessageBox.Show("Vui lòng chọn nghiệp vụ.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var obj = new Q_ServiceStep();
                    obj.Id        = Id;
                    obj.MajorId   = int.Parse(gridViewStep.GetRowCellValue(gridViewStep.FocusedRowHandle, "MajorId").ToString());
                    obj.ServiceId = serId;
                    obj.Index     = int.Parse(gridViewStep.GetRowCellValue(gridViewStep.FocusedRowHandle, "Index").ToString());

                    if (obj.Id == 0)
                    {
                        int result = BLLServiceStep.Instance.Insert(connect, obj);
                        if (result == 0)
                        {
                            MessageBox.Show("Dịch vụ đã tồn tại nghiệp vụ này. Xin chọn lại nghiệp vụ khác", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            goto End;
                        }
                    }
                    else
                    {
                        bool result = BLLServiceStep.Instance.Update(connect, obj);
                        if (result == false)
                        {
                            MessageBox.Show("Dịch vụ đã tồn tại nghiệp vụ này. Xin chọn lại nghiệp vụ khác", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            goto End;
                        }
                    }
                    GetGridServiceStep();
                }
            }
            catch (Exception ex) { }
            End : { }
        }
Exemplo n.º 2
0
        //public List<ModelSelectItem> GetLookUp()
        //{
        //      using (db = new QMSSystemEntities()){
        //    return db.Q_ServiceStep.Where(x => !x.IsDeleted).Select(x => new ModelSelectItem() { Id = x.Id, Name = x.Name }).ToList();
        //}

        public int Insert(Q_ServiceStep obj)
        {
            using (db = new QMSSystemEntities()){
                if (!CheckExists(obj))
                {
                    db.Q_ServiceStep.Add(obj);
                    db.SaveChanges();
                }
                return(obj.Id);
            }
        }
Exemplo n.º 3
0
 public bool Update(Q_ServiceStep model)
 {
     using (db = new QMSSystemEntities()){
         var obj = db.Q_ServiceStep.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id);
         if (obj != null)
         {
             if (!CheckExists(model))
             {
                 obj.ServiceId = model.ServiceId;
                 obj.MajorId   = model.MajorId;
                 obj.Index     = model.Index;
                 db.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         return(false);
     }
 }
Exemplo n.º 4
0
        private bool CheckExists(Q_ServiceStep model)
        {
            var obj = db.Q_ServiceStep.FirstOrDefault(x => !x.IsDeleted && x.Id != model.Id && x.ServiceId == model.ServiceId && x.MajorId == model.MajorId);

            return(obj != null ? true : false);
        }