private void btnSaveAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (!ValidateForm())
         {
             return;
         }
         if (!CheckCodeIsExists())
         {
             return;
         }
         if (SaveData() == (int)EnumResultInsertUpdate.Success)
         {
             DsDictionary.AcceptChanges();
             // Khởi tạo dòng mới
             FormActionMode = ActionMode.AddNew;
             LoadDataForm();
         }
         else if (SaveData() == (int)EnumResultInsertUpdate.DuplicateCode)
         {
             MessageBoxCommon.ShowExclamation("Trùng mã");
         }
         else if (SaveData() == (int)EnumResultInsertUpdate.Failed)
         {
             MessageBoxCommon.ShowExclamation("Lưu dữ liệu thất bại");
         }
     }
     catch (Exception ex)
     {
         MessageBoxCommon.ShowException(ex);
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateForm())
                {
                    return;
                }
                if (!CheckCodeIsExists())
                {
                    return;
                }
                var result = SaveData();

                if (result == (int)EnumResultInsertUpdate.Success)
                {
                    //if (BsDetail.DataMember != "Order")
                    //{
                    DsDictionary.AcceptChanges();
                    DialogResult = DialogResult.OK;
                    //}
                }
                else if (result == (int)EnumResultInsertUpdate.DuplicateCode)
                {
                    if (CurrentRow.Table == DsDictionary.Area || CurrentRow.Table == DsDictionary.Unit)
                    {
                        MessageBoxCommon.ShowExclamation("Trùng tên");
                    }
                    else
                    {
                        MessageBoxCommon.ShowExclamation("Trùng mã");
                    }
                }
                else if (result == (int)EnumResultInsertUpdate.Failed)
                {
                    MessageBoxCommon.ShowExclamation("Lưu dữ liệu thất bại");
                }
            }
            catch (Exception ex)
            {
                MessageBoxCommon.ShowException(ex);
            }
        }
Exemple #3
0
 private void btnSendKitchen_Click(object sender, EventArgs e)
 {
     try
     {
         int countSendKitchen = 0;
         var oBLSendKitchen   = new BLSendKitchen();
         foreach (var item in fpnlChooseFood.Controls)
         {
             if (item.GetType() == typeof(UctChooseFood))
             {
                 UctChooseFood uct = (UctChooseFood)item;
                 if (!uct.IsSendKitchen)
                 {
                     countSendKitchen++;
                     // Insert To SendKitchen
                     var sendKitchenRow = oBLSendKitchen.InitNewRow(dsDictionary.SendKitchen, uct.OrderDetailRow.OrderDetailID);
                     oBLSendKitchen.InsertUpdate(sendKitchenRow);
                     // Update detail
                     uct.OrderDetailRow.OrderDetailStatus = (int)EnumOrderDetailStatus.Served;
                     uct.IsSendKitchen = true;
                 }
             }
         }
         if (SaveData() > 0)
         {
             FormActionMode = ActionMode.Edit;
             DsDictionary.AcceptChanges();
         }
         if (countSendKitchen == 0)
         {
             MessageBoxCommon.ShowExclamation("Không có món nào mới để gửi bếp.");
         }
         else
         {
             IsSendKitchen = true;
         }
     }
     catch (Exception ex)
     {
         MessageBoxCommon.ShowException(ex);
     }
 }