Ejemplo n.º 1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (!CheckData())
         {
             return;
         }
         //Table Mold
         Mold mold = new Mold();
         mold.Id     = _id;
         mold.MoldNo = txtMoldNo.Text.Trim();
         mold.Note   = txtNote.Text.Trim();
         mold.Status = (chkUsing.Checked ? GlobalConstants.StatusValue.Using : GlobalConstants.StatusValue.NoUse);
         _moldRepository.Save(mold);
         UnitOfWork unitOfWork = new UnitOfWork(_projectDataContext);
         int        result     = unitOfWork.Complete();
         if (result > 0)
         {
             if (String.IsNullOrEmpty(_id))
             {
                 if (_quickAdd)
                 {
                     this.Tag     = txtMoldNo.Text.Trim();
                     DialogResult = DialogResult.OK;
                     Close();
                 }
                 else
                 {
                     XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Lưu thành công"), LanguageTranslate.ChangeLanguageText("Thông báo"));
                     Clear();
                 }
             }
             else
             {
                 DialogResult = DialogResult.OK;
                 Close();
             }
         }
         else
         {
             XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Lưu thất bại"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Lưu thất bại"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
 }