public async static Task<PRO_tblDistrictDRO> InsertUpdateDistrict(PRO_tblDistrictDTO item, SYS_tblActionLogDTO actionLog) { PRO_tblDistrictDRO result = new PRO_tblDistrictDRO(); try { string url = string.Format(@"{0}/InsertUpdateDistrict", GetBaseUrl()); var postData = new PRO_tblDistrictDCO { DistrictID = item.DistrictID, DistrictCode = item.DistrictCode, VNName = item.VNName, ENName = item.ENName, ProvinceID = item.ProvinceID, Rank = item.Rank, Used = item.Used, Note = item.Note, Activity = item.Activity, UserID = item.UserID, LanguageID = item.LanguageID }; var json_data = "{\"district\":" + JsonConvert.SerializeObject(postData, new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.MicrosoftDateFormat }) + "}"; result = await PRO_tblDistrictDAO.InsertUpdateDistrict(url, json_data); if (string.IsNullOrEmpty(result.ResponseItem.Message)) result.ResponseItem = await SYS_tblActionLogBUS.InsertUpdateLog(actionLog); } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
public async static Task<PRO_tblDistrictDRO> InsertUpdateDistrict(string url, string json_data) { PRO_tblDistrictDRO result = new PRO_tblDistrictDRO(); try { var response_data = await HttpPost(url, json_data); if (response_data.ToLower().StartsWith("error")) { result.ResponseItem.IsError = true; string[] tmp = response_data.Split('|'); result.ResponseItem.ErrorCode = tmp[1]; result.ResponseItem.ErrorMessage = tmp[2]; } else { var response_collection = JsonConvert.DeserializeObject<PRO_tblDistrictDRO>(response_data + ""); if (response_collection != null) { result.ResponseItem = response_collection.ResponseItem; } } } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
public async static Task<PRO_tblDistrictDRO> GetDistrictItem(string username, string language_id, string district_id) { PRO_tblDistrictDRO result = new PRO_tblDistrictDRO(); try { string url = string.Format(@"{0}/GetDistrictByID?Username={1}&LanguageID={2}&DistrictID={3}", GetBaseUrl(), username, language_id, district_id); result = await PRO_tblDistrictDAO.GetDistrictItem(url); } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
public async static Task<PRO_tblDistrictDRO> GetAllDistricts(string username, string language_id, bool is_combobox, string province_id, SYS_tblActionLogDTO actionLog) { PRO_tblDistrictDRO result=new PRO_tblDistrictDRO(); try { string url = string.Format(@"{0}/GetAllDistrict?Username={1}&LanguageID={2}&ProvinceID={3}&GetCombobox={4}", GetBaseUrl(), username, language_id, province_id, is_combobox ? "True" : "False"); result = await PRO_tblDistrictDAO.GetAllDistricts(url); if (string.IsNullOrEmpty(result.ResponseItem.Message)) if (actionLog != null) result.ResponseItem = await SYS_tblActionLogBUS.InsertUpdateLog(actionLog); } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
public async static Task<PRO_tblDistrictDRO> DeleteDistrict(string username, string language_id, string district_id_list, SYS_tblActionLogDTO actionLog) { PRO_tblDistrictDRO result = new PRO_tblDistrictDRO(); try { string url = string.Format(@"{0}/DeleteDistrict?Username={1}&LanguageID={2}&DistrictIDList={3}", GetBaseUrl(), username, language_id, district_id_list); result = await PRO_tblDistrictDAO.DeleteDistrict(url); if (string.IsNullOrEmpty(result.ResponseItem.Message)) result.ResponseItem = await SYS_tblActionLogBUS.InsertUpdateLog(actionLog); } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
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; }
private async Task DeleteDistrict() { district_code_list = ""; district_id_list = ""; foreach (int index in grvDistrict.GetSelectedRows()) { district_code_list = string.Join("$", district_code_list, grvDistrict.GetRowCellDisplayText(index, gcolDistrictCode)); district_id_list = string.Join("$", district_id_list, grvDistrict.GetRowCellDisplayText(index, gcolDistrictID)); } if (district_code_list.Length > 0) district_code_list = district_code_list.Substring(1); if (district_id_list.Length > 0) district_id_list = district_id_list.Substring(1); PRO_tblDistrictDRO result = new PRO_tblDistrictDRO(); result.ResponseItem.Message = "ready"; if (!string.IsNullOrEmpty(district_id_list)) { try { if (district_id_list.Contains("$")) { if (CommonEngine.ShowConfirmMessageAlert(LanguageEngine.GetMessageCaption("000012", ConfigEngine.Language).Replace("$Count$", district_id_list.Split('$').Length.ToString()))) { CommonEngine.ShowWaitForm(this); result = await PRO_tblDistrictBUS.DeleteDistrict(CommonEngine.userInfo.Username, ConfigEngine.Language, district_id_list, new SYS_tblActionLogDTO { Activity = BaseConstant.COMMAND_INSERT_EN, UserID = CommonEngine.userInfo.UserID, LanguageID = ConfigEngine.Language, ActionVN = BaseConstant.COMMAND_DELETE_VI, ActionEN = BaseConstant.COMMAND_DELETE_EN, FunctionID = "12", DescriptionVN = string.Format("Tài khoản '{0}' vừa xóa thành công những quận huyện có mã '{1}'.", CommonEngine.userInfo.UserID, district_code_list.Replace("$", ", ")), DescriptionEN = string.Format("Account '{0}' has deleted districts successfully with district codes are '{1}'.", CommonEngine.userInfo.UserID, district_code_list.Replace("$", ", ")) }); } } else { if (CommonEngine.ShowConfirmMessageAlert(LanguageEngine.GetMessageCaption("000005", ConfigEngine.Language))) { CommonEngine.ShowWaitForm(this); result = await PRO_tblDistrictBUS.DeleteDistrict(CommonEngine.userInfo.Username, ConfigEngine.Language, district_id_list, new SYS_tblActionLogDTO { Activity = BaseConstant.COMMAND_INSERT_EN, UserID = CommonEngine.userInfo.UserID, LanguageID = ConfigEngine.Language, ActionVN = BaseConstant.COMMAND_DELETE_VI, ActionEN = BaseConstant.COMMAND_DELETE_EN, FunctionID = "12", DescriptionVN = string.Format("Tài khoản '{0}' vừa xóa thành công quận huyện có mã '{1}'.", CommonEngine.userInfo.UserID, district_code_list), DescriptionEN = string.Format("Account '{0}' has deleted district successfully with district code is '{1}'.", CommonEngine.userInfo.UserID, district_code_list) }); } } if (!CommonEngine.CheckValidResponseItem(result.ResponseItem)) return; if (!result.ResponseItem.Message.Equals("ready")) if (string.IsNullOrEmpty(result.ResponseItem.Message)) GetAllDistrict(); else CommonEngine.ShowMessage(result.ResponseItem.Message, 0); } catch (Exception ex) { CommonEngine.ShowExceptionMessage(ex); } finally { CommonEngine.CloseWaitForm(); } } else CommonEngine.ShowMessage("000027", IMC.Helper.MessageType.Warning, true); }