Exemplo n.º 1
0
 public int Insert(Q_CommandParameter obj)
 {
     using (db = new QMSSystemEntities()){
         db.Q_CommandParameter.Add(obj);
         db.SaveChanges();
         return(obj.Id);
     }
 }
Exemplo n.º 2
0
 public bool Update(Q_CommandParameter model)
 {
     using (db = new QMSSystemEntities()){
         var obj = db.Q_CommandParameter.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id);
         if (obj != null)
         {
             obj.CommandId = model.CommandId;
             obj.Parameter = model.Parameter;
             obj.Note      = model.Note;
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
Exemplo n.º 3
0
        private void gridViewCommandParameter_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                int Id = 0;
                int.TryParse(gridViewCommandParameter.GetRowCellValue(gridViewCommandParameter.FocusedRowHandle, "Id").ToString(), out Id);
                if (Id == 0 && string.IsNullOrEmpty(gridViewCommandParameter.GetRowCellValue(gridViewCommandParameter.FocusedRowHandle, "Parameter").ToString()))
                {
                    goto End;
                }

                if (Id != 0 && string.IsNullOrEmpty(gridViewCommandParameter.GetRowCellValue(gridViewCommandParameter.FocusedRowHandle, "Parameter").ToString()))
                {
                    MessageBox.Show("Vui lòng nhập tham số lệnh.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var obj = new Q_CommandParameter();
                    obj.Id        = Id;
                    obj.Parameter = gridViewCommandParameter.GetRowCellValue(gridViewCommandParameter.FocusedRowHandle, "Parameter").ToString();
                    obj.CommandId = commandId;
                    obj.Note      = gridViewCommandParameter.GetRowCellValue(gridViewCommandParameter.FocusedRowHandle, "Note") != null?gridViewCommandParameter.GetRowCellValue(gridViewCommandParameter.FocusedRowHandle, "Note").ToString() : "";

                    if (obj.Id == 0)
                    {
                        BLLCommandParameter.Instance.Insert(connect, obj);
                    }
                    else
                    {
                        BLLCommandParameter.Instance.Update(connect, obj);
                    }
                    GetGridCommandParameter();
                }
            }
            catch (Exception ex)
            { }
End:
            { }
        }