コード例 #1
0
 public int Insert(Q_MaindisplayDirection obj)
 {
     using (db = new QMSSystemEntities())
     {
         if (!CheckExists(obj))
         {
             db.Q_MaindisplayDirection.Add(obj);
             db.SaveChanges();
         }
         return(obj.Id);
     }
 }
コード例 #2
0
        private void gridViewMaindisplayDirection_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                int Id = 0;
                int.TryParse(gridViewMaindisplayDirection.GetRowCellValue(gridViewMaindisplayDirection.FocusedRowHandle, "Id").ToString(), out Id);
                if (Id == 0 && gridViewMaindisplayDirection.GetRowCellValue(gridViewMaindisplayDirection.FocusedRowHandle, "EquipmentId").ToString() == "0" || int.Parse(gridViewMaindisplayDirection.GetRowCellValue(gridViewMaindisplayDirection.FocusedRowHandle, "EquipmentId").ToString()) == 0)
                {
                    goto End;
                }
                //else if (Id == 0 && string.IsNullOrEmpty(gridViewMaindisplayDirection.GetRowCellValue(gridViewMaindisplayDirection.FocusedRowHandle, "Index").ToString()) || int.Parse(gridViewMaindisplayDirection.GetRowCellValue(gridViewMaindisplayDirection.FocusedRowHandle, "Index").ToString()) == 0)
                //    goto End;

                if (Id != 0 && (gridViewMaindisplayDirection.GetRowCellValue(gridViewMaindisplayDirection.FocusedRowHandle, "EquipmentId").ToString() == "0") || int.Parse(gridViewMaindisplayDirection.GetRowCellValue(gridViewMaindisplayDirection.FocusedRowHandle, "EquipmentId").ToString()) == 0)
                {
                    MessageBox.Show("Vui lòng chọn thiết bị", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                //else if (Id != 0 && string.IsNullOrEmpty(gridViewMaindisplayDirection.GetRowCellValue(gridViewMaindisplayDirection.FocusedRowHandle, "ShiftId").ToString()))
                //    MessageBox.Show("Vui lòng chọn thời gian cấp phiếu dịch vụ.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                else
                {
                    var obj = new Q_MaindisplayDirection();
                    obj.Id          = Id;
                    obj.EquipmentId = int.Parse(gridViewMaindisplayDirection.GetRowCellValue(gridViewMaindisplayDirection.FocusedRowHandle, "EquipmentId").ToString());
                    obj.CounterId   = counterId;
                    obj.Direction   = (bool)gridViewMaindisplayDirection.GetRowCellValue(gridViewMaindisplayDirection.FocusedRowHandle, "Direction");
                    obj.Note        = gridViewMaindisplayDirection.GetRowCellValue(gridViewMaindisplayDirection.FocusedRowHandle, "Note") != null?gridViewMaindisplayDirection.GetRowCellValue(gridViewMaindisplayDirection.FocusedRowHandle, "Note").ToString() : null;

                    if (obj.Id == 0)
                    {
                        int result = BLLMaindisplayDirection.Instance.Insert(obj);
                        if (result == 0)
                        {
                            MessageBox.Show("Đã tồn tại Quầy có hướng đi Maindisplay này. Xin chọn lại", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            goto End;
                        }
                    }
                    else
                    {
                        bool result = BLLMaindisplayDirection.Instance.Update(obj);
                        if (result == false)
                        {
                            MessageBox.Show("Đã tồn tại Quầy có hướng đi Maindisplay này. Xin chọn lại", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            goto End;
                        }
                    }
                    GetGrid();
                }
            }
            catch (Exception ex) { }
            End : { }
        }
コード例 #3
0
 public bool Update(Q_MaindisplayDirection model)
 {
     using (db = new QMSSystemEntities())
     {
         if (!CheckExists(model))
         {
             var obj = db.Q_MaindisplayDirection.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id);
             if (obj != null)
             {
                 obj.CounterId   = model.CounterId;
                 obj.EquipmentId = model.EquipmentId;
                 obj.Direction   = model.Direction;
                 obj.Note        = model.Note;
                 db.SaveChanges();
                 return(true);
             }
         }
         return(false);
     }
 }
コード例 #4
0
        private bool CheckExists(Q_MaindisplayDirection model)
        {
            var obj = db.Q_MaindisplayDirection.FirstOrDefault(x => !x.IsDeleted && x.Id != model.Id && x.CounterId == model.CounterId && x.EquipmentId == model.EquipmentId);

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