示例#1
0
 public int Insert(Q_Sound obj)
 {
     using (db = new QMSSystemEntities()){
         db.Q_Sound.Add(obj);
         db.SaveChanges();
         return(obj.Id);
     }
 }
示例#2
0
 public int Insert(string connectString, Q_Sound obj)
 {
     using (db = new QMSSystemEntities(connectString)){
         db.Q_Sound.Add(obj);
         db.SaveChanges();
         return(obj.Id);
     }
 }
示例#3
0
        private void gridViewSound_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                int Id = 0;
                int.TryParse(gridViewSound.GetRowCellValue(gridViewSound.FocusedRowHandle, "Id").ToString(), out Id);
                if (Id == 0 && string.IsNullOrEmpty(gridViewSound.GetRowCellValue(gridViewSound.FocusedRowHandle, "Name").ToString()))
                {
                    goto End;
                }
                if (Id == 0 && int.Parse(gridViewSound.GetRowCellValue(gridViewSound.FocusedRowHandle, "LanguageId").ToString()) == 0)
                {
                    goto End;
                }

                if (Id != 0 && string.IsNullOrEmpty(gridViewSound.GetRowCellValue(gridViewSound.FocusedRowHandle, "Name").ToString()))
                {
                    MessageBox.Show("Vui lòng nhập mã trạng thái.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (Id != 0 && int.Parse(gridViewSound.GetRowCellValue(gridViewSound.FocusedRowHandle, "LanguageId").ToString()) == 0)
                {
                    MessageBox.Show("Vui lòng chọn ngôn ngữ.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var obj = new Q_Sound();
                    obj.Id         = Id;
                    obj.Name       = gridViewSound.GetRowCellValue(gridViewSound.FocusedRowHandle, "Name").ToString();
                    obj.LanguageId = int.Parse(gridViewSound.GetRowCellValue(gridViewSound.FocusedRowHandle, "LanguageId").ToString());
                    obj.Code       = gridViewSound.GetRowCellValue(gridViewSound.FocusedRowHandle, "Code") != null?gridViewSound.GetRowCellValue(gridViewSound.FocusedRowHandle, "Code").ToString() : "";

                    obj.Note = gridViewSound.GetRowCellValue(gridViewSound.FocusedRowHandle, "Note") != null?gridViewSound.GetRowCellValue(gridViewSound.FocusedRowHandle, "Note").ToString() : "";

                    if (obj.Id == 0)
                    {
                        BLLSound.Instance.Insert(connect, obj);
                    }
                    else
                    {
                        BLLSound.Instance.Update(connect, obj);
                    }
                    GetGridSound();
                    frmMain.lib_Sounds = BLLSound.Instance.Gets(connect);
                }
            }
            catch (Exception ex)
            {
            }
End:
            {
            }
        }
示例#4
0
 public bool Update(Q_Sound model)
 {
     using (db = new QMSSystemEntities()){
         var obj = db.Q_Sound.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id);
         if (obj != null)
         {
             obj.Code       = model.Code;
             obj.Name       = model.Name;
             obj.LanguageId = model.LanguageId;
             obj.Note       = model.Note;
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
 }