예제 #1
0
        private async Task <bool> SaveDistrict(bool isEdit)
        {
            PRO_tblDistrictDRO result = new PRO_tblDistrictDRO();

            CommonEngine.ShowWaitForm(this);
            try
            {
                result = await iPOS.BUS.Products.PRO_tblDistrictBUS.InsertUpdateDistrict(new PRO_tblDistrictDTO
                {
                    DistrictID   = isEdit ? txtDistrictID.Text : "0",
                    DistrictCode = txtDistrictCode.Text,
                    VNName       = txtVNName.Text,
                    ENName       = txtENName.Text,
                    ProvinceID   = gluProvince.EditValue + "",
                    Rank         = speRank.EditValue != null ? Convert.ToInt32(speRank.Value) : (Int32?)null,
                    Used         = chkUsed.Checked,
                    Note         = mmoNote.Text,
                    UserID       = CommonEngine.userInfo.UserID,
                    Activity     = (isEdit) ? BaseConstant.COMMAND_UPDATE_EN : BaseConstant.COMMAND_INSERT_EN,
                    LanguageID   = ConfigEngine.Language
                }, new DTO.Systems.SYS_tblActionLogDTO
                {
                    Activity      = BaseConstant.COMMAND_INSERT_EN,
                    UserID        = CommonEngine.userInfo.UserID,
                    LanguageID    = ConfigEngine.Language,
                    ActionEN      = isEdit ? BaseConstant.COMMAND_UPDATE_EN : BaseConstant.COMMAND_INSERT_EN,
                    ActionVN      = isEdit ? BaseConstant.COMMAND_UPDATE_VI : BaseConstant.COMMAND_INSERT_VI,
                    FunctionID    = "12",
                    DescriptionVN = string.Format("Tài khoản '{0}' vừa {1} thành công quận huyện có mã quận huyện là '{2}'.", CommonEngine.userInfo.UserID, isEdit ? "cập nhật" : "thêm mới", txtDistrictCode.Text),
                    DescriptionEN = string.Format("Account '{0}' has {1} district successfully with district code is '{2}'.", CommonEngine.userInfo.UserID, isEdit ? "updated" : "inserted", txtDistrictCode.Text)
                });

                if (result.ResponseItem.IsError)
                {
                    CommonEngine.CloseWaitForm();
                    CommonEngine.ShowHTTPErrorMessage(result.ResponseItem);
                    txtDistrictCode.Focus();
                    return(false);
                }
                if (!string.IsNullOrEmpty(result.ResponseItem.Message))
                {
                    CommonEngine.CloseWaitForm();
                    CommonEngine.ShowMessage(result.ResponseItem.Message, 0);
                    txtDistrictCode.Focus();
                    return(false);
                }
                else if (parent_form != null)
                {
                    parent_form.GetAllDistrict();
                }
            }
            catch (Exception ex)
            {
                CommonEngine.ShowExceptionMessage(ex);
                return(false);
            }
            finally
            {
                CommonEngine.CloseWaitForm();
            }

            return(true);
        }