Esempio n. 1
0
        private void gridViewChild_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                int Id = 0;
                int.TryParse(gridViewChild.GetRowCellValue(gridViewChild.FocusedRowHandle, "Id").ToString(), out Id);
                if (Id == 0 && string.IsNullOrEmpty(gridViewChild.GetRowCellValue(gridViewChild.FocusedRowHandle, "SoundName").ToString()))
                {
                    goto End;
                }
                else if (Id == 0 && string.IsNullOrEmpty(gridViewChild.GetRowCellValue(gridViewChild.FocusedRowHandle, "LanguageId").ToString()))
                {
                    goto End;
                }

                if (Id != 0 && string.IsNullOrEmpty(gridViewChild.GetRowCellValue(gridViewChild.FocusedRowHandle, "SoundName").ToString()))
                {
                    MessageBox.Show("Vui lòng nhập tên tệp âm thanh.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (Id != 0 && string.IsNullOrEmpty(gridViewChild.GetRowCellValue(gridViewChild.FocusedRowHandle, "LanguageId").ToString()))
                {
                    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_CounterSound();
                    obj.Id         = Id;
                    obj.SoundName  = gridViewChild.GetRowCellValue(gridViewChild.FocusedRowHandle, "SoundName").ToString();
                    obj.LanguageId = (int)gridViewChild.GetRowCellValue(gridViewChild.FocusedRowHandle, "LanguageId");
                    obj.CounterId  = counterId;
                    obj.Note       = gridViewChild.GetRowCellValue(gridViewChild.FocusedRowHandle, "Note") != null?gridViewChild.GetRowCellValue(gridViewChild.FocusedRowHandle, "Note").ToString() : "";

                    int kq = 0;
                    if (obj.Id == 0)
                    {
                        kq = BLLCounterSound.Instance.Insert(obj);
                    }
                    else
                    {
                        kq = BLLCounterSound.Instance.Update(obj);
                    }

                    if (kq == 0)
                    {
                        MessageBox.Show("Tên tệp với ngôn ngữ này đã tồn tại. Xin nhập tên khác", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        goto End;
                    }
                    else
                    {
                        GetGridChild();
                    }
                }
            }
            catch (Exception ex)
            {
            }
            End : { }
        }
Esempio n. 2
0
 public int Insert(string connectString, Q_CounterSound obj)
 {
     using (db = new QMSSystemEntities(connectString))
     {
         if (!CheckExists(obj))
         {
             db.Q_CounterSound.Add(obj);
             db.SaveChanges();
         }
         return(obj.Id);
     }
 }
Esempio n. 3
0
        private void gridViewCounterSound_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                int Id = 0;
                int.TryParse(gridViewCounterSound.GetRowCellValue(gridViewCounterSound.FocusedRowHandle, "Id").ToString(), out Id);
                if (Id == 0 && (string.IsNullOrEmpty(gridViewCounterSound.GetRowCellValue(gridViewCounterSound.FocusedRowHandle, "CounterId").ToString()) || gridViewCounterSound.GetRowCellValue(gridViewCounterSound.FocusedRowHandle, "CounterId").ToString() == "0"))
                {
                    goto End;
                }
                else if (Id == 0 && (string.IsNullOrEmpty(gridViewCounterSound.GetRowCellValue(gridViewCounterSound.FocusedRowHandle, "SoundId").ToString()) || gridViewCounterSound.GetRowCellValue(gridViewCounterSound.FocusedRowHandle, "SoundId").ToString() == "0"))
                {
                    goto End;
                }

                if (Id != 0 && (string.IsNullOrEmpty(gridViewCounterSound.GetRowCellValue(gridViewCounterSound.FocusedRowHandle, "CounterId").ToString()) || gridViewCounterSound.GetRowCellValue(gridViewCounterSound.FocusedRowHandle, "CounterId").ToString() == "0"))
                {
                    MessageBox.Show("Vui lòng chọn Quầy.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (Id != 0 && (string.IsNullOrEmpty(gridViewCounterSound.GetRowCellValue(gridViewCounterSound.FocusedRowHandle, "SoundId").ToString()) || gridViewCounterSound.GetRowCellValue(gridViewCounterSound.FocusedRowHandle, "SoundId").ToString() == "0"))
                {
                    MessageBox.Show("Vui lòng chọn Âm thanh.", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var obj = new Q_CounterSound();
                    obj.Id        = Id;
                    obj.CounterId = int.Parse(gridViewCounterSound.GetRowCellValue(gridViewCounterSound.FocusedRowHandle, "CounterId").ToString());
                    obj.SoundName = gridViewCounterSound.GetRowCellValue(gridViewCounterSound.FocusedRowHandle, "SoundId").ToString();
                    obj.Note      = gridViewCounterSound.GetRowCellValue(gridViewCounterSound.FocusedRowHandle, "Note") != null?gridViewCounterSound.GetRowCellValue(gridViewCounterSound.FocusedRowHandle, "Note").ToString() : "";

                    if (obj.Id == 0)
                    {
                        BLLCounterSound.Instance.Insert(connect, obj);
                    }
                    else
                    {
                        BLLCounterSound.Instance.Update(connect, obj);
                    }
                    GetGridCounterSound();
                    frmMain.lib_CounterSound = BLLCounterSound.Instance.Gets(connect);
                }
            }
            catch (Exception ex)
            {
            }
End:
            {
            }
        }
Esempio n. 4
0
 public int Update(string connectString, Q_CounterSound model)
 {
     using (db = new QMSSystemEntities(connectString))
     {
         var obj = db.Q_CounterSound.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id);
         if (obj != null)
         {
             if (!CheckExists(model))
             {
                 obj.SoundName  = model.SoundName;
                 obj.LanguageId = model.LanguageId;
                 obj.Note       = model.Note;
                 obj.CounterId  = model.CounterId;
                 db.SaveChanges();
                 return(model.Id);
             }
             else
             {
                 return(0);
             }
         }
         return(0);
     }
 }
Esempio n. 5
0
        private bool CheckExists(Q_CounterSound model)
        {
            var obj = db.Q_CounterSound.FirstOrDefault(x => !x.IsDeleted && x.Id != model.Id && x.CounterId == model.CounterId && x.LanguageId == model.LanguageId && x.SoundName.Trim().ToUpper().Equals(model.SoundName.Trim().ToUpper()));

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