private async Task SetAds(Guid simGuid) { try { if (simGuid == Guid.Empty) { return; } var list = await SimcardAdsBussines.GetAllAsync(simGuid); if (list.Count <= 0) { return; } foreach (var item in list) { for (var i = 0; i < dgAds.RowCount; i++) { if (item.Advertise == ((Guid?)dgAds[dg_AdvGuid.Index, i].Value ?? Guid.Empty)) { dgAds[dg_AdvChecked.Index, i].Value = true; } } } } catch (Exception e) { WebErrorLog.ErrorInstence.StartErrorLog(e); } }
private async void btnInsSimcardAds_Click(object sender, EventArgs e) { for (int i = 0; i < dgSimcardAds.RowCount; i++) { if ((bool)dgSimcardAds[dg_isChecked.Index, i].Value) { var a = new SimcardAdsBussines() { Guid = Guid.NewGuid(), DateSabt = DateConvertor.M2SH(DateTime.Now), Status = true, SimcardGuid = (Guid)cmbSimcard.SelectedValue, // Advertise = dgSimcardAds[dg_AdvName.Index, i].Value.ToString() }; await a.SaveAsync(); } } }
private async void btnFinish_Click(object sender, EventArgs e) { try { btnFinish.Enabled = false; if (cls.Guid == Guid.Empty) { cls.Guid = Guid.NewGuid(); cls.DateSabt = DateConvertor.M2SH(DateTime.Now); } if (string.IsNullOrWhiteSpace(txtNumber.Text)) { WebErrorLog.ErrorInstence.StartErrorLog("لطفا شماره را وارد نمایید", false); txtNumber.Focus(); return; } if (txtNumber.Text.Length < 10 || txtNumber.Text.Length > 12) { WebErrorLog.ErrorInstence.StartErrorLog("شماره وارد شده اشتباه است", false); txtNumber.Focus(); return; } if (!SimcardBussines.Check_Number(long.Parse(txtNumber.Text), cls.Guid)) { WebErrorLog.ErrorInstence.StartErrorLog("شماره وارد شده تکراری است", false); txtNumber.Focus(); return; } if (string.IsNullOrWhiteSpace(txtOwner.Text)) { WebErrorLog.ErrorInstence.StartErrorLog("لطفا مالک را وارد نمایید", false); txtNumber.Focus(); return; } if (string.IsNullOrWhiteSpace(cmbOperator.Text)) { WebErrorLog.ErrorInstence.StartErrorLog("لطفا اپراتور را وارد نمایید", false); txtNumber.Focus(); return; } if (!chbIsEnableNumber.Checked && !chbIsEnableChat.Checked) { WebErrorLog.ErrorInstence.StartErrorLog( "بنابر قوانین سایت دیوار و شیپور، حداقل یکی از گزینه های نمایش شماره یا ارسال چت باید فعال باشد", false); chbIsEnableNumber.Focus(); return; } var listCity = new List <DivarSimCityBussines>(); for (int i = 0; i < dgCity.RowCount; i++) { if ((bool)dgCity[dg_CityChecked.Index, i].Value) { var a = new DivarSimCityBussines() { Guid = Guid.NewGuid(), DateSabt = DateConvertor.M2SH(DateTime.Now), Status = true, SimcardGuid = cls.Guid, CityGuid = (Guid)dgCity[dg_CityGuid.Index, i].Value }; listCity.Add(a); } } var listCitySh = new List <SheypoorSimCityBussines>(); for (int i = 0; i < dgSheypoorCity.RowCount; i++) { if ((bool)dgSheypoorCity[dg_SheypoorCityChecked.Index, i].Value) { var a = new SheypoorSimCityBussines() { Guid = Guid.NewGuid(), DateSabt = DateConvertor.M2SH(DateTime.Now), Status = true, SimcardGuid = cls.Guid, CityGuid = (Guid)dgSheypoorCity[dg_SheypoorCityGuid.Index, i].Value, StateGuid = (Guid)dgSheypoorCity[dg_StateGuid.Index, i].Value }; listCitySh.Add(a); } } var listAds = new List <SimcardAdsBussines>(); for (int i = 0; i < dgAds.RowCount; i++) { if ((bool)dgAds[dg_AdvChecked.Index, i].Value) { var a = new SimcardAdsBussines() { Guid = Guid.NewGuid(), DateSabt = DateConvertor.M2SH(DateTime.Now), Status = true, SimcardGuid = cls.Guid, Advertise = (Guid)dgAds[dg_AdvGuid.Index, i].Value }; listAds.Add(a); } } cls.OwnerName = txtOwner.Text; cls.Status = true; cls.Number = long.Parse(txtNumber.Text); cls.NextUse = DateTime.Now; cls.Operator = cmbOperator.Text; cls.UserName = txtUserName.Text; cls.DivarPostCat1 = (Guid?)cmbPostCat1.SelectedValue ?? null; cls.DivarPostCat2 = (Guid?)cmbPostCat2.SelectedValue ?? null; cls.DivarPostCat3 = (Guid?)cmbPostCat3.SelectedValue ?? null; cls.IsEnableChat = chbIsEnableChat.Checked; cls.IsEnableNumber = chbIsEnableNumber.Checked; cls.IsSendAdv = chbIsSendAdvDivar.Checked; cls.IsSendAdvSheypoor = chbIsSendAdvSheypoor.Checked; cls.IsSendChat = chbIsSendChatDivar.Checked; cls.IsSendChatSheypoor = chbIsSendChatSheypoor.Checked; cls.ChatCount = int.Parse(txtChatCount.Text); cls.DivarCityForChat = (Guid)cmbDivarCity.SelectedValue; cls.SheypoorCityForChat = (Guid)cmbSheypoorCity.SelectedValue; cls.DivarChatCat1 = (Guid)cmbDivarChat1.SelectedValue; cls.DivarChatCat2 = (Guid)cmbDivarChat2.SelectedValue; cls.DivarChatCat3 = (Guid?)cmbDivarChat3.SelectedValue ?? Guid.Empty; cls.SheypoorChatCat1 = (Guid)cmbSheypoorChat1.SelectedValue; cls.SheypoorChatCat2 = (Guid)cmbSheypoorChat2.SelectedValue; cls.isSendPostToTelegram = chbIsSendPostToTelegram.Checked; cls.ChannelForSendPost = txtChannel.Text; cls.PostCount = txtPostCount.Text?.ParseToInt() ?? null; cls.CityForGetPost = (Guid?)cmbPostCity.SelectedValue ?? null; cls.DescriptionForPost = txtPostDescription.Text; cls.isSendSecondChat = chbIsSendSecondText.Checked; cls.FirstChatPassage = txtFirstChatPassage1.Text; cls.FirstChatPassage2 = txtFirstChatPassage2.Text; cls.FirstChatPassage3 = txtFirstChatPassage3.Text; cls.FirstChatPassage4 = txtFirstChatPassage4.Text; cls.SecondChatPassage = txtSecondChatPassage1.Text; cls.FirstChatPassage2 = txtFirstChatPassage2.Text; cls.FirstChatPassage3 = txtFirstChatPassage3.Text; cls.FirstChatPassage4 = txtFirstChatPassage4.Text; cls.SMS_Description = txtSMS.Text; await cls.SaveAsync(listCity, listAds, listCitySh); DialogResult = DialogResult.OK; Close(); } catch (Exception exception) { WebErrorLog.ErrorInstence.StartErrorLog(exception); } finally { btnFinish.Enabled = true; } }