private void ButtonReport_Click(object sender, RoutedEventArgs e) { this.ForceCursor = true; Cursor tmp = this.Cursor; this.Cursor = Cursors.Wait; IEnumerable <SubscriptionsTb> Tb = (IEnumerable <SubscriptionsTb>)DataGridView.ItemsSource; if (Tb != null) { if (Tb.ToList().Count > 0) { DataTable Dt = Commons.ToDataTable <SubscriptionsTb>(Tb); Dt.TableName = "DebtorsReport"; PrintPreviewDialog PrintPrv = new PrintPreviewDialog(@"Reports\DebtorsReport.mrt", GridHeader.Background, "بدهکاران", Dt); PrintPrv.ShowDialog(); } else { MessageDialog Msg = new MessageDialog(Messages.PrintMessageTitleSubScription, Messages.DataNotFoundForPrint, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } else { MessageDialog Msg = new MessageDialog(Messages.PrintMessageTitleSubScription, Messages.DataNotFoundForPrint, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } this.Cursor = tmp; }
private void UserControlBilling_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if (((bool)e.NewValue)) { int Ch = CheckPeriod(); if (Ch == -1) { EmptyControl(); TextBlockPeriod.Text = ""; TextBoxSubScriptionId.Text = ""; TextBoxCurrentReadDate.Text = ""; TextBoxSubScriptionId.IsEnabled = false; TextBoxCurrentRead.IsEnabled = false; TextBoxCurrentReadDate.IsEnabled = false; MessageDialog Msg = new MessageDialog(Messages.SaveMessageTitleBillsReceivable, Messages.NotExistPeriodBilling, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); Ac.ShowWindow("BillsReceivable", "MainMenu"); return; } else { if (Ch == -2) { EmptyControl(); TextBlockPeriod.Text = ""; TextBoxSubScriptionId.Text = ""; TextBoxCurrentReadDate.Text = ""; TextBoxSubScriptionId.IsEnabled = false; TextBoxCurrentRead.IsEnabled = false; TextBoxCurrentReadDate.IsEnabled = false; MessageDialog Msg = new MessageDialog(Messages.SaveMessageTitleBillsReceivable, Messages.PeriodIsClosedBillingReceivable, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } else { TextBoxSubScriptionId.IsEnabled = true; TextBoxCurrentRead.IsEnabled = true; TextBoxCurrentReadDate.IsEnabled = true; FirstControl.Focus(); FirstControl.SelectAll(); } } if (Commons.EditAccountType[2] == true || Commons.EditCustomer[2] == true || Commons.EditSubScription[1] == true || Commons.EditBillPeriod[1] == true || Commons.EditSettings[2] == true) { EmptyControl(); TextBoxSubScriptionId.Text = ""; TextBoxCurrentReadDate.Text = Commons.GetCurrentPersianDate(); Commons.EditAccountType[2] = false; Commons.EditCustomer[2] = false; Commons.EditSubScription[1] = false; Commons.EditBillPeriod[1] = false; Commons.EditSettings[2] = false; } } }
private void ButtonCloseYear_Click(object sender, RoutedEventArgs e) { MessageDialog Msg = null; try { if (ComboBoxCurrentYear.SelectedIndex < 1) { Msg = new MessageDialog(Messages.CloseYearTitleSettings, Messages.YearNotSelected, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); ComboBoxCurrentYear.Focus(); Msg.ShowDialog(); return; } var Ly = Commons.Db.Years.Select(x => x).ToList(); bool IsAllowToClose = false; YearsTb SelectedYear = null; foreach (YearsTb value in Ly) { if (value.Year == Commons.CurrentYear && value.IsClosed == false) { IsAllowToClose = true; SelectedYear = value; break; } } if (IsAllowToClose == false) { Msg = new MessageDialog(Messages.CloseYearTitleSettings, Messages.CloseYearImpossible, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } else { Msg = new MessageDialog(Messages.CloseYearTitleSettings, Messages.IsCloseYear, MessageDialogButtons.YesNo, MessageDialogType.Information, GridHeader.Background); Msg.Owner = Window.GetWindow(this); if (Msg.ShowDialog() == true) { SelectedYear.IsClosed = true; Commons.IsClosedCurrentYear = true; Commons.Db.SaveChanges(); Commons.SetFromEdited("Settings"); Msg = new MessageDialog(Messages.CloseYearTitleSettings, Messages.CloseYearMessageSuccess, MessageDialogButtons.Ok, MessageDialogType.Information, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } } catch { Msg = new MessageDialog(Messages.CloseYearTitleSettings, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } }
private void ButtonSendSms_Click(object sender, RoutedEventArgs e) { this.ForceCursor = true; Cursor tmp = this.Cursor; this.Cursor = Cursors.Wait; IEnumerable <DomainClasses.BillsVw> Tb = (IEnumerable <DomainClasses.BillsVw>)DataGridView.ItemsSource; if (Tb != null) { if (Tb.ToList().Count > 0) { var Msg = new MessageDialog(Messages.TitleSendSmsToDebtors, Messages.AreyouSureToSendSms, MessageDialogButtons.YesNo, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); if (Msg.ShowDialog() == true) { List <SmsInfo> SmsList = new List <SmsInfo>(); foreach (var Row in Tb.ToList()) { SmsInfo info = new SmsInfo() { SubId = Row.SubscriptionId, Cellphone = Row.CellPhone, Message = TextBoxSmsMessage.Text.Replace("[Name]", Row.Name.Trim()) .Replace("[Family]", Row.Family.Trim()) .Replace("[SubscriptionId]", Row.SubscriptionId.Trim()) .Replace("[WaterMeterSerial]", Row.WaterMeterSerial.Trim()) .Replace("[PrevReadDate]", Row.PrevReadDate.Trim()) .Replace("[CurrentReadDate]", Row.CurrentReadDate.Trim()) .Replace("[Consumption]", Row.Consumption.ToString().Trim()) .Replace("[Debt]", Commons.ConvertToMoney(Row.Debt.ToString().Trim())) .Replace("[PaymentDeadLine]", Commons.GetDeadLinePaymentDate().Trim()) }; SmsList.Add(info); } var SmsSentDetials = new SmsSentDetails(SmsList); SmsSentDetials.Owner = Window.GetWindow(this); SmsSentDetials.ShowDialog(); } } else { MessageDialog Msg = new MessageDialog(Messages.TitleSendSmsToDebtors, Messages.DataNotFoundForSms, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } else { MessageDialog Msg = new MessageDialog(Messages.TitleSendSmsToDebtors, Messages.DataNotFoundForSms, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } this.Cursor = tmp; }
private void ButtonCreateYear_Click(object sender, RoutedEventArgs e) { MessageDialog Msg = null; try { List <YearsTb> Ly = Commons.Db.Years.Select(x => x).OrderBy(x => x.Year).ToList(); bool IsCreate = true; int NewYear = 0; foreach (YearsTb value in Ly) { NewYear = value.Year; if (value.IsClosed == false) { IsCreate = false; break; } } if (IsCreate == false) { Commons.Db.SaveChanges(); Msg = new MessageDialog(Messages.CreateYearTitleSettings, Messages.CreateYearImpossible, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } else { if (NewYear == 0) { NewYear = Commons.GetCurrentYear(); } else { NewYear++; } Commons.Db.Years.Add(new YearsTb { IsClosed = false, Year = NewYear }); Commons.Db.SaveChanges(); ComboBoxCurrentYear.Items.Add(NewYear); Msg = new MessageDialog(Messages.CreateYearTitleSettings, Messages.CreateYearMessageSuccessSettings, MessageDialogButtons.Ok, MessageDialogType.Information, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } catch { Msg = new MessageDialog(Messages.CreateYearTitleSettings, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } }
private void ButtonPeriodClose_Click(object sender, RoutedEventArgs e) { MessageDialog Msg = null; DomainClasses.BillPeriodsTb MyBillPeriod = null; MyBillPeriod = Commons.Db.BillPeriods.Find(BillPeriodId); if (MyBillPeriod != null) { try { if (MyBillPeriod.IsSelected) { if (MyBillPeriod.IsClosed == false) { Msg = new MessageDialog(Messages.CloseMessageTitleBillPeriods, Messages.PeriodsIsClosed, MessageDialogButtons.YesNo, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); if (Msg.ShowDialog() == true) { MyBillPeriod.IsClosed = true; Commons.Db.SaveChanges(); Commons.SetFromEdited("BillPeriods"); DataGridView.ItemsSource = Commons.Db.BillPeriods.Select(x => x).Where(x => x.Year == Commons.CurrentYear).OrderBy(x => x.DateFrom).ToList(); DataGridView.Items.Refresh(); Msg = new MessageDialog(Messages.CloseMessageTitleBillPeriods, Messages.ClosedMessageSuccessed, MessageDialogButtons.Ok, MessageDialogType.Information, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } else { Msg = new MessageDialog(Messages.CloseMessageTitleBillPeriods, Messages.PeriodClosed, MessageDialogButtons.Ok, MessageDialogType.Information, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } else { Msg = new MessageDialog(Messages.CloseMessageTitleBillPeriods, Messages.ImpossibleClosedMessage, MessageDialogButtons.Ok, MessageDialogType.Information, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } catch { Msg = new MessageDialog(Messages.CloseMessageTitleBillPeriods, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } else { } }
private void ButtonShowEdit_Click(object sender, RoutedEventArgs e) { MessageDialog Msg; try { string id = ((TextBlock)DataGridView.Columns[0].GetCellContent(DataGridView.SelectedItem)).Text; SubscriptionsTb RowEdited = Commons.Db.Subscriptions.Find(id, Commons.CurrentYear); if (RowEdited != null) { TextBoxSubScriptionId.Text = id.Trim(); TextBoxCustomerId.Text = RowEdited.CustomerId.ToString(); ReturnInfoCustomer(RowEdited.CustomerId); int Id = 0; foreach (object value in ComboBoxAccountType.Items) { Id = (int)((ComboBoxItem)value).Tag; if (Id == RowEdited.AccountTypeId) { ComboBoxAccountType.SelectedItem = value; } } foreach (object value in ComboBoxPreventType.Items) { Id = (int)((ComboBoxItem)value).Tag; if (Id == RowEdited.PreventTypeId) { ComboBoxPreventType.SelectedItem = value; } } TextBoxWaterMeterSerial.Text = RowEdited.WaterMeter.WaterMeterSerial.Trim(); TextBoxWaterMeterNumber.Text = RowEdited.PrevNumber.ToString().Trim(); TextBoxNumberReadDate.Text = RowEdited.PrevReadDate.Trim(); TextBoxPostalCode.Text = RowEdited.PostalCode.Trim(); TextBoxAddress.Text = RowEdited.Address.Trim(); TextBoxComments.Text = RowEdited.Description.Trim(); TextBlockCurrentNumber.Text = RowEdited.CurrentNumber.ToString(); TextBlockCurrentReadDate.Text = RowEdited.CurrentReadDate.Trim(); TextBoxDebt.Text = Commons.ConvertToMoneyWithSign(RowEdited.Debt); TextBoxDeficit1000.Text = Commons.ConvertToMoneyWithSign(RowEdited.deficit1000); ButtonDefination_Click(ButtonDefination, null); } } catch { Msg = new MessageDialog(Messages.EditMessageTitleSubscriptions, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } }
private void CheckSubScriptionId() { CurrentSubscriptionBilling = null; BindingOperations.GetBindingExpression(FirstControl, TextBox.TextProperty).UpdateSource(); MessageDialog Msg = null; try { bool IsValid = true; string SId = ""; ControlsValidate?Vd = Commons.ValidateData((Control)FirstControl, ControlsArraySubScriptionId); if (Vd != null) { IsValid = false; Msg = new MessageDialog(Messages.SaveMessageTitleBillsCancelling, Messages.ForceToSubscriptionId, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); EmptyControl(); FirstControl.Focus(); FirstControl.SelectAll(); } if (IsValid == true) { SId = TextBoxSubScriptionId.Text.Trim(); CurrentSubscriptionBilling = LoadSubscriptionForBilling(SId); if (CurrentSubscriptionBilling != null) { FillSubScription(CurrentSubscriptionBilling); ButtonCancel.Focus(); } else { Msg = new MessageDialog(Messages.SaveMessageTitleBillsCancelling, Messages.NotFoundSubscriptionOrBillForCancelling, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); EmptyControl(); FirstControl.Focus(); FirstControl.SelectAll(); } } } catch { Msg = new MessageDialog(Messages.SaveMessageTitleBillsCancelling, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); FirstControl.Focus(); FirstControl.SelectAll(); } }
private void ButtonDelete_Click(object sender, RoutedEventArgs e) { MessageDialog Msg; string id = ((TextBlock)DataGridView.Columns[0].GetCellContent(DataGridView.SelectedItem)).Text; SubscriptionsTb RowDeleted = Commons.Db.Subscriptions.Find(id, Commons.CurrentYear); if (RowDeleted != null) { try { if (CheckSubscriptionInUse(RowDeleted) == false) { Msg = new MessageDialog(Messages.DeleteMessageTitleSubscriptions, Messages.DeleteMessageSubscriptions, MessageDialogButtons.YesNo, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); if (Msg.ShowDialog() == true) { WaterMetersTb Wd = Commons.Db.WaterMeters.Find(RowDeleted.WaterMeterId, Commons.CurrentYear); if (Wd != null) { Commons.Db.WaterMeters.Remove(Wd); } Commons.Db.Subscriptions.Remove(RowDeleted); Commons.Db.SaveChanges(); Commons.SetFromEdited("SubScriptions"); List <SubscriptionsTb> L = (List <SubscriptionsTb>)DataGridView.ItemsSource; if (L != null) { L.Remove(RowDeleted); } SearchAgain = true; DataGridView.Items.Refresh(); Msg = new MessageDialog(Messages.DeleteMessageTitleSubscriptions, Messages.DeleteMessageSuccessSubscriptions, MessageDialogButtons.Ok, MessageDialogType.Information, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } else { Msg = new MessageDialog(Messages.DeleteMessageTitleSubscriptions, Messages.SubScriptInUseDelete, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } catch { Msg = new MessageDialog(Messages.DeleteMessageTitleSubscriptions, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } }
private void ButtonShowEdit_Click(object sender, RoutedEventArgs e) { MessageDialog Msg; try { ContentPresenter fe = (ContentPresenter)DataGridView.Columns[7].GetCellContent(DataGridView.SelectedItem); StackPanel S = (StackPanel)fe.ContentTemplate.FindName("StackEditDelete", fe); string id = ((TextBlock)S.FindName("Id")).Text; BillPeriodsTb RowEdited = Commons.Db.BillPeriods.Find(Convert.ToInt32(id)); if (RowEdited != null) { TextBoxPeriodName.IsEnabled = true; TextBoxComments.IsEnabled = true; TextBoxCountOfMonth.IsEnabled = true; BillPeriodId = Convert.ToInt32(id); if (RowEdited.IsSelected) { RadioYes.IsChecked = true; } else { RadioNo.IsChecked = true; } TextBoxPeriodName.Text = RowEdited.Name.Trim(); TextBoxCountOfMonth.Text = RowEdited.MonthPeriod.ToString(); TextBoxCountOfMonth.IsEnabled = false; TextBlockMonths.Text = GetNameOFMonthsInPeriod(RowEdited.DateFrom, RowEdited.DateTo); TextBoxComments.Text = RowEdited.Description.Trim(); if (RowEdited.IsClosed) { TextBoxPeriodName.IsEnabled = false; TextBoxComments.IsEnabled = false; RadioYes.Focus(); } else { FirstControl.Focus(); } } } catch { Msg = new MessageDialog(Messages.EditMessageTitleBillPeriods, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } }
private void UserControlReports_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if (((bool)e.NewValue)) { int Ch = CheckPeriod(); if (Ch == -1) { MessageDialog Msg = new MessageDialog(Messages.PrintMessageReports, Messages.NotExistPeriodBilling, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); Ac.ShowWindow("Reports", "MainMenu"); return; } } }
private void ButtonDelete_Click(object sender, RoutedEventArgs e) { MessageDialog Msg; try { long id = Convert.ToInt64(((TextBlock)DataGridAccountTypes.Columns[0].GetCellContent(DataGridAccountTypes.SelectedItem)).Text); AccountTypesTb RowDeleted = Commons.Db.AccountTypes.Find(id, Commons.CurrentYear); if (RowDeleted != null) { var Sub = Commons.Db.Subscriptions.Local.Where(x => x.AccountTypeId == id); if (Sub.Count <SubscriptionsTb>() == 0) { Msg = new MessageDialog(Messages.DeleteMessageTitleAccountTypes, Messages.DeleteMessageAccountTypes, MessageDialogButtons.YesNo, MessageDialogType.Warning, GridHeaderAccountTypes.Background); Msg.Owner = Window.GetWindow(this); if (Msg.ShowDialog() == true) { Commons.Db.AccountTypes.Remove(RowDeleted); Commons.Db.SaveChanges(); Commons.SetFromEdited("AccountTypes"); List <AccountTypesTb> L = (List <AccountTypesTb>)DataGridAccountTypes.ItemsSource; if (L != null) { L.Remove(RowDeleted); } SearchAgain = true; DataGridAccountTypes.Items.Refresh(); Msg = new MessageDialog(Messages.DeleteMessageTitleAccountTypes, Messages.DeleteMessageSuccessAccountTypes, MessageDialogButtons.Ok, MessageDialogType.Information, GridHeaderAccountTypes.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } else { Msg = new MessageDialog(Messages.DeleteMessageTitleAccountTypes, Messages.DeleteAccountTypeImpossible, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeaderAccountTypes.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } } catch { Msg = new MessageDialog(Messages.DeleteMessageTitleAccountTypes, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeaderAccountTypes.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } }
private void Button_Click(object sender, RoutedEventArgs e) { MessageDialog Msg; if (Commons.EditSettings[0] == true) { Commons.SetYear(); Commons.EditSettings[0] = false; } if (Commons.CurrentYear <= 0 && ((Button)sender).Tag.ToString() != "Settings" && ((Button)sender).Tag.ToString() != "About") { Msg = new MessageDialog(Messages.SplashLoading, Messages.MainMenuYearNotSelected, MessageDialogButtons.Ok, MessageDialogType.Warning, new SolidColorBrush(Color.FromRgb(0, 25, 65))); Msg.ShowDialog(); } else { Ac.ShowWindow("MainMenu", ((Button)sender).Tag.ToString()); } }
private void ButtonNotBill_Click(object sender, RoutedEventArgs e) { MessageDialog Msg; this.ForceCursor = true; Cursor tmp = this.Cursor; this.Cursor = Cursors.Wait; try { IEnumerable <SubscriptionsTb> Tb = (IEnumerable <SubscriptionsTb>)Commons.Db.Subscriptions.SqlQuery("select * from SubscriptionsTbs where SubscriptionsTbs.Year = " + Commons.CurrentYear.ToString() + " AND Not Exists(select * from BillsTbs where BillsTbs.SubscriptionId = SubscriptionsTbs.Id AND BillsTbs.Year = SubscriptionsTbs.Year AND CurrentPeriod = " + Commons.CPeriod.Id.ToString() + " AND BillsTbs.Status != 1)"); if (Tb != null) { if (Tb.ToList().Count > 0) { DataTable Dt = Commons.ToDataTable <SubscriptionsTb>(Tb); Dt.TableName = "Subscriptions"; PrintPreviewDialog PrintPrv = new PrintPreviewDialog(@"Reports\SubscriptionsReport.mrt", GridHeader.Background, "اشتراکاتی که در دوره جاری برایشان قبض صادر نشده است", Dt); PrintPrv.ShowDialog(); } else { Msg = new MessageDialog(Messages.PrintMessageReports, Messages.DataNotFoundForPrint, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } else { Msg = new MessageDialog(Messages.PrintMessageReports, Messages.DataNotFoundForPrint, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } catch { Msg = new MessageDialog(Messages.PrintMessageReports, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } this.Cursor = tmp; }
private void ButtonTalab_Click(object sender, RoutedEventArgs e) { MessageDialog Msg; this.ForceCursor = true; Cursor tmp = this.Cursor; this.Cursor = Cursors.Wait; try { IEnumerable <SubscriptionsTb> Tb = (IEnumerable <SubscriptionsTb>)Commons.Db.Subscriptions.Where(x => x.Debt < 0 && x.Year == Commons.CurrentYear); if (Tb != null) { if (Tb.ToList().Count > 0) { DataTable Dt = Commons.ToDataTable <SubscriptionsTb>(Tb); Dt.TableName = "Subscriptions"; PrintPreviewDialog PrintPrv = new PrintPreviewDialog(@"Reports\SubscriptionsReport.mrt", GridHeader.Background, "بستانکاران اشتراک", Dt); PrintPrv.ShowDialog(); } else { Msg = new MessageDialog(Messages.PrintMessageReports, Messages.DataNotFoundForPrint, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } else { Msg = new MessageDialog(Messages.PrintMessageReports, Messages.DataNotFoundForPrint, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } catch { Msg = new MessageDialog(Messages.PrintMessageReports, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } this.Cursor = tmp; }
private void ButtonReport_Click(object sender, RoutedEventArgs e) { this.ForceCursor = true; Cursor tmp = this.Cursor; this.Cursor = Cursors.Wait; IEnumerable <BillingDetails> Tb = (IEnumerable <BillingDetails>)DataGridView.ItemsSource; if (Tb != null) { if (Tb.ToList().Count > 0) { DataTable Dt = Commons.ToDataTable <BillingDetails>(Tb); Dt.TableName = "BillsPeriod"; string FullName = Tb.FirstOrDefault().Name.Trim() + " " + Tb.FirstOrDefault().Family.Trim(); string FromDateToDate = ""; if (!string.IsNullOrWhiteSpace(TextBoxDateFrom.Text.Trim())) { FromDateToDate = " از " + TextBoxDateFrom.Text.Trim(); } if (!string.IsNullOrWhiteSpace(TextBoxDateTo.Text.Trim())) { FromDateToDate += (" تا " + TextBoxDateTo.Text.Trim()); } PrintPreviewDialog PrintPrv = new PrintPreviewDialog(@"Reports\OneSubBillForAllPeriod.mrt", GridHeader.Background, "قبوض دوره های اشتراک" + " : " + TextBoxSubScriptionId.Text.Trim() + " / " + FullName + FromDateToDate, Dt); PrintPrv.ShowDialog(); } else { MessageDialog Msg = new MessageDialog(Messages.PrintMessageTitleSubScription, Messages.DataNotFoundForPrint, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } else { MessageDialog Msg = new MessageDialog(Messages.PrintMessageTitleSubScription, Messages.DataNotFoundForPrint, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } this.Cursor = tmp; }
private void UserControlBilling_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if (((bool)e.NewValue)) { if (FormLoaded == true || Commons.EditAccountType[1] == true || Commons.EditCustomer[1] == true || Commons.EditSubScription[0] == true || Commons.EditBillPeriod[0] == true) { Wd = new WaitingDialog(Messages.LoadSubTitle, Messages.WaitingLoadSub, GridHeader.Background); Wd.Show(); LoadThisPeriodBillsList = true; if (LoadFirst() == -1) { MessageDialog Msg = new MessageDialog(Messages.SaveMessageTitleBilling, Messages.NotExistPeriodBilling, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.ShowDialog(); TextBoxCurrentRead.SelectAll(); } Commons.EditAccountType[1] = false; Commons.EditCustomer[1] = false; Commons.EditSubScription[0] = false; Commons.EditBillPeriod[0] = false; FormLoaded = false; Wd.Close(); } else { if (CurrentPeriodIsFilled) { MessageDialog Msg = new MessageDialog(Messages.SaveMessageTitleBilling, Messages.SubScriptionNextNotFound, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.ShowDialog(); TextBoxCurrentRead.SelectAll(); } if (CurentPeriodNotSelectedOrNotCreated) { MessageDialog Msg = new MessageDialog(Messages.SaveMessageTitleBilling, Messages.NotExistPeriodBilling, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.ShowDialog(); TextBoxCurrentRead.SelectAll(); } } } }
private void ButtonShowEdit_Click(object sender, RoutedEventArgs e) { MessageDialog Msg; try { long id = Convert.ToInt64(((TextBlock)DataGridCustomers.Columns[0].GetCellContent(DataGridCustomers.SelectedItem)).Text); CustomersTb RowEdited = Commons.Db.Customers.Find(id, Commons.CurrentYear); if (RowEdited != null) { CustomerId = id; TextBoxMeliCode.Text = RowEdited.MeliCode.Trim(); TextBoxName.Text = RowEdited.Name.Trim(); TextBoxFamily.Text = RowEdited.Family.Trim(); TextBoxFather.Text = RowEdited.Father.Trim(); TextBoxIdCard.Text = RowEdited.IdCard.Trim(); TextBoxCityCard.Text = RowEdited.CityCard.Trim(); TextBoxPhone.Text = RowEdited.Phone.Trim(); TextBoxCellPhone.Text = RowEdited.CellPhone.Trim(); TextBoxPostalCode.Text = RowEdited.PostalCode.Trim(); TextBoxAddress.Text = RowEdited.Address.Trim(); TextBoxComments.Text = RowEdited.Description.Trim(); ButtonCustomer_Click(ButtonCustomer, null); } else { Msg = new MessageDialog(Messages.EditMessageTitleCustomers, Messages.CustomerNotFound, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeaderCustomers.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } catch { Msg = new MessageDialog(Messages.EditMessageTitleCustomers, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeaderCustomers.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } }
private void DoNext() { MessageDialog Msg; int FeedBack = LoadNextSubScription(); if (FeedBack == -1) { Msg = new MessageDialog(Messages.SaveMessageTitleBilling, Messages.SubScriptionNextNotFound, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.ShowDialog(); TextBoxCurrentRead.SelectAll(); } else if (FeedBack == -2) { Msg = new MessageDialog(Messages.SaveMessageTitleBilling, Messages.SubScriptionIsWrong, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.ShowDialog(); TextBoxCurrentRead.SelectAll(); } else if (FeedBack == -3) { Msg = new MessageDialog(Messages.SaveMessageTitleBilling, Messages.SubScriptionNotFound, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.ShowDialog(); TextBoxCurrentRead.SelectAll(); } }
private void ButtonShowEdit_Click(object sender, RoutedEventArgs e) { MessageDialog Msg; try { long id = Convert.ToInt64(((TextBlock)DataGridAccountTypes.Columns[0].GetCellContent(DataGridAccountTypes.SelectedItem)).Text); AccountTypesTb RowEdited = Commons.Db.AccountTypes.Find(id, Commons.CurrentYear); if (RowEdited != null) { AccountTypeId = id; TextBoxName.Text = RowEdited.Name.Trim(); TextBoxFormules.Text = RowEdited.Formules.Trim(); TextBoxComments.Text = RowEdited.Description.Trim(); ButtonAccountType_Click(ButtonAccountType, null); } } catch { Msg = new MessageDialog(Messages.EditMessageTitleAccountTypes, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeaderAccountTypes.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } }
private void ReturnInfoCustomer(long CId) { MessageDialog Msg = null; try { CustomersTb Row = Commons.Db.Customers.Find(CId, Commons.CurrentYear); if (Row != null) { TextBlockName.Text = Row.Name; TextBlockFamily.Text = Row.Family; TextBlockFather.Text = Row.Father; TextBlockMelicode.Text = Row.MeliCode; TextBlockPostalCode.Text = Row.MeliCode; TextBlockAddress.Text = Row.Address; } else { Msg = new MessageDialog(Messages.SearchMessageTitleCustomers, Messages.NotFoundCustomers, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); TextBlockName.Text = ""; TextBlockFamily.Text = ""; TextBlockFather.Text = ""; TextBlockMelicode.Text = ""; TextBlockPostalCode.Text = ""; TextBlockAddress.Text = ""; } } catch { Msg = new MessageDialog(Messages.SearchMessageTitleCustomers, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } }
private void ButtonSave_Click(object sender, RoutedEventArgs e) { ControlsValidate?Vd = Commons.ValidateData(FirstControl, ControlsArray); MessageDialog Msg = null; if (Commons.CPeriod.Id > 0 && Commons.CPeriod.IsClosed == false) { if (Vd != null) { Msg = new MessageDialog(Messages.SaveMessageTitleBillsCancelling, Vd.Value.Message, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); Vd.Value.Control.Focus(); } else { DomainClasses.SubscriptionsTb MySubscription = CurrentSubscriptionBilling.SubScription; //در صورتی که قبض مربوطه مربوط به کنتور قبلی باشد امکان ابطال آن وجود ندارد if (CurrentSubscriptionBilling.SubScription.WaterMeterId == CurrentSubscriptionBilling.Bill.WaterMeterId && CurrentSubscriptionBilling.SubScription.WaterMeterYear == CurrentSubscriptionBilling.Bill.WaterMeterYear) { Msg = new MessageDialog(Messages.SaveMessageTitleBillsCancelling, Messages.SaveMessageBillsCancelling, MessageDialogButtons.YesNo, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); if (Msg.ShowDialog() == true) { try { long PrevDebt = CurrentSubscriptionBilling.Bill.PrevDebt; long PrevDeficit1000 = CurrentSubscriptionBilling.Bill.Prevdeficit1000; string PrevPrevReadDate = CurrentSubscriptionBilling.Bill.PrevPrevReadDate , PrevReadDate = MySubscription.PrevReadDate; long PrevPrevNumber = CurrentSubscriptionBilling.Bill.PrevPrevNumber , PrevNumber = MySubscription.PrevNumber; if (CurrentSubscriptionBilling.Bill.Status == BillsStatus.ReceivableFull || CurrentSubscriptionBilling.Bill.Status == BillsStatus.ReceivableNotMatch) { PrevDebt = PrevDebt - CurrentSubscriptionBilling.Bill.ReceivablePrice; PrevDeficit1000 = PrevDeficit1000 - CurrentSubscriptionBilling.Bill.ReceivableDefict1000; } CurrentSubscriptionBilling.Bill.CancelDate = Commons.GetCurrentPersianDate(); CurrentSubscriptionBilling.Bill.Status = BillsStatus.Cancel; MySubscription.Debt = PrevDebt; MySubscription.deficit1000 = PrevDeficit1000; MySubscription.PrevReadDate = PrevPrevReadDate; MySubscription.PrevNumber = PrevPrevNumber; MySubscription.CurrentReadDate = PrevReadDate; MySubscription.CurrentNumber = PrevNumber; //به روز رسانی آخرین قرائت با کنتور فعلی MySubscription.WaterMeter.ReadEnd = PrevNumber; MySubscription.WaterMeter.ReadDateEnd = PrevReadDate; Commons.Db.SaveChanges(); Msg = new MessageDialog(Messages.SaveMessageTitleBillsCancelling, Messages.SaveMessageSuccessBillsCancelling, MessageDialogButtons.Ok, MessageDialogType.Information, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); EmptyControl(); TextBoxSubScriptionId.Text = ""; TextBoxSubScriptionId.Focus(); TextBoxSubScriptionId.SelectAll(); } catch { Msg = new MessageDialog(Messages.SaveMessageTitleBillsCancelling, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); ButtonCancel.Focus(); } } } //در صورتی که قبض مربوطه مربوط به کنتور قبلی باشد امکان ابطال آن وجود ندارد else { Msg = new MessageDialog(Messages.SaveMessageTitleBillsCancelling, Messages.CanNotCancelBillBecauseOfWaterMeter, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); ButtonCancel.Focus(); } } } else { Msg = new MessageDialog(Messages.SaveMessageTitleBillsCancelling, Messages.NotExistPeriodBilling, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); TextBoxSubScriptionId.Text = ""; TextBoxSubScriptionId.Focus(); TextBoxSubScriptionId.SelectAll(); } }
private void ButtonDelete_Click(object sender, RoutedEventArgs e) { MessageDialog Msg = null; try { ContentPresenter fe = (ContentPresenter)DataGridView.Columns[7].GetCellContent(DataGridView.SelectedItem); StackPanel S = (StackPanel)fe.ContentTemplate.FindName("StackEditDelete", fe); string id = ((TextBlock)S.FindName("Id")).Text; BillPeriodsTb RowDeleted = Commons.Db.BillPeriods.Find(Convert.ToInt32(id)); if (RowDeleted != null) { if (CheckPervRowIsExist(RowDeleted) == true) { Msg = new MessageDialog(Messages.DeleteMessageTitleBillPeriods, Messages.PrevRowExits, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); DataGridView.Focus(); } else { if (CheckPeriodIsUsed(RowDeleted) == true) { Msg = new MessageDialog(Messages.DeleteMessageTitleBillPeriods, Messages.PeriodInUseDelete, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); DataGridView.Focus(); } else { if (RowDeleted.IsClosed == true) { Msg = new MessageDialog(Messages.DeleteMessageTitleBillPeriods, Messages.DeletePeriodIsClosedBillPeriods, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); DataGridView.Focus(); } else { Msg = new MessageDialog(Messages.DeleteMessageTitleBillPeriods, Messages.DeleteMessageBillPeriods, MessageDialogButtons.YesNo, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); if (Msg.ShowDialog() == true) { Commons.Db.BillPeriods.Remove(RowDeleted); Commons.Db.SaveChanges(); Commons.SetFromEdited("BillPeriods"); DataGridView.ItemsSource = Commons.Db.BillPeriods.Select(x => x).Where(x => x.Year == Commons.CurrentYear).OrderBy(x => x.DateFrom).ToList(); DataGridView.Items.Refresh(); Msg = new MessageDialog(Messages.DeleteMessageTitleBillPeriods, Messages.DeleteMessageSuccessBillPeriods, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); DataGridView.Focus(); } } } } } } catch { Msg = new MessageDialog(Messages.DeleteMessageTitleBillPeriods, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); DataGridView.Focus(); } }
private void DoSearch() { string SubScriptionIdFromText = ""; string DateFrom = ""; bool DateFromFlag = true; string DateTo = ""; bool DateToFlag = true; ControlsValidate?Vd = Commons.ValidateData(FirstControl, ControlsArrayForValidation); if (Vd != null) { MessageDialog Msg = null; Msg = new MessageDialog(Messages.SaveMessageTitleSingleBilling, Vd.Value.Message, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); Vd.Value.Control.Focus(); } else { if (!string.IsNullOrWhiteSpace(TextBoxSubScriptionId.Text)) { string[] Tmp = TextBoxSubScriptionId.Text.Trim().Split(new char[] { '-' }); if (Tmp != null && Tmp.Length == 2) { SubScriptionIdFromText = TextBoxSubScriptionId.Text.Trim(); // Convert.ToInt32(Tmp[0]).ToString("0000") + "-" + Convert.ToInt32(Tmp[1]).ToString("00000"); } else { MessageDialog Msg = new MessageDialog(Messages.PrintMessageTitleSubScription, Messages.ValueIsSubscriptionNumberStart + "از شماره اشتراک" + Messages.ValueIsSubscriptionNumberEnd, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); return; } } else { MessageDialog Msg = new MessageDialog(Messages.PrintMessageTitleSubScription, Messages.SubIdIsMandatory, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); return; } if (TextBoxDateFrom.Text.Trim() != "" && TextBoxDateTo.Text.Trim() != "") { DateFrom = TextBoxDateFrom.Text.Trim(); DateFromFlag = false; DateTo = TextBoxDateTo.Text.Trim(); DateToFlag = false; } else { if (TextBoxDateFrom.Text.Trim() != "") { DateFrom = TextBoxDateFrom.Text.Trim(); DateFromFlag = false; } if (TextBoxDateTo.Text.Trim() != "") { DateTo = TextBoxDateTo.Text.Trim(); DateToFlag = false; } } DataGridView.ItemsSource = LoadBillsForDataGrid(SubScriptionIdFromText, DateFromFlag, DateFrom, DateToFlag, DateTo); } }
private void ButtonSave_Click(object sender, RoutedEventArgs e) { ControlsValidate?Vd = Commons.ValidateData(FirstControl, ControlsArray); MessageDialog Msg = null; if (Vd != null) { Msg = new MessageDialog(Messages.SaveMessageTitleBillPeriods, Vd.Value.Message, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); Vd.Value.Control.Focus(); } else { int Len = Convert.ToInt32(TextBoxCountOfMonth.Text); int Start = 0; string[] DateFromTo = null; DomainClasses.BillPeriodsTb MyBillPeriod = null; MyBillPeriod = Commons.Db.BillPeriods.Find(BillPeriodId); if (MyBillPeriod == null) { Start = IsPeriodOk(Len); if (Start == -1) { Msg = new MessageDialog(Messages.SaveMessageTitleBillPeriods, Messages.PeriodNotInRange, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); TextBoxCountOfMonth.Focus(); TextBoxCountOfMonth.SelectAll(); return; } DateFromTo = GetDateFromAndDateTo(Start, Len); if (RadioYes.IsChecked == true) { if (!IsPeriodSelecetedOK(-1, DateFromTo[0])) { Msg = new MessageDialog(Messages.SaveMessageTitleBillPeriods, Messages.IsNotPossibeToSelect, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); RadioYes.Focus(); return; } } Msg = new MessageDialog(Messages.SaveMessageTitleBillPeriods, Messages.SaveMessageBillPeriods, MessageDialogButtons.YesNo, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); if (Msg.ShowDialog() == true) { try { if (RadioYes.IsChecked == true) { var Bls = Commons.Db.BillPeriods.Select(x => x).Where(x => x.IsSelected == true && x.Year == Commons.CurrentYear); foreach (BillPeriodsTb value in Bls) { value.IsSelected = false; } } Commons.Db.BillPeriods.Add(new DomainClasses.BillPeriodsTb { Year = Commons.CurrentYear, IsSelected = Convert.ToBoolean(RadioYes.IsChecked), IsClosed = false, Name = TextBoxPeriodName.Text.Trim(), DateFrom = DateFromTo[0].Trim(), DateTo = DateFromTo[1].Trim(), MonthPeriod = Len, Description = TextBoxComments.Text.Trim() }); Commons.Db.SaveChanges(); Commons.SetFromEdited("BillPeriods"); DataGridView.ItemsSource = Commons.Db.BillPeriods.Select(x => x).Where(x => x.Year == Commons.CurrentYear).OrderBy(x => x.DateFrom).ToList(); DataGridView.Items.Refresh(); Msg = new MessageDialog(Messages.SaveMessageBillPeriods, Messages.SaveMessageSuccessBillPeriods, MessageDialogButtons.Ok, MessageDialogType.Information, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); ButtonNew_Click(null, null); } catch { Msg = new MessageDialog(Messages.SaveMessageTitleBillPeriods, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } } else { DateFromTo = new string[2]; DateFromTo[0] = MyBillPeriod.DateFrom; DateFromTo[1] = MyBillPeriod.DateTo; if (RadioYes.IsChecked == true) { if (!IsPeriodSelecetedOK(MyBillPeriod.Id, DateFromTo[0])) { Msg = new MessageDialog(Messages.SaveMessageTitleBillPeriods, Messages.IsNotPossibeToSelect, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); RadioYes.Focus(); return; } } Msg = new MessageDialog(Messages.EditMessageTitleBillPeriods, Messages.EditMessageBillPeriods, MessageDialogButtons.YesNo, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); if (Msg.ShowDialog() == true) { try { if (MyBillPeriod.IsClosed != true) { MyBillPeriod.Description = TextBoxComments.Text.Trim(); MyBillPeriod.Name = TextBoxPeriodName.Text.Trim(); } if (RadioYes.IsChecked == true) { var Bls = Commons.Db.BillPeriods.Select(x => x).Where(x => x.IsSelected == true && x.Year == Commons.CurrentYear); foreach (BillPeriodsTb value in Bls) { value.IsSelected = false; } } MyBillPeriod.IsSelected = Convert.ToBoolean(RadioYes.IsChecked); Commons.Db.SaveChanges(); Commons.SetFromEdited("BillPeriods"); DataGridView.ItemsSource = Commons.Db.BillPeriods.Select(x => x).Where(x => x.Year == Commons.CurrentYear).OrderBy(x => x.DateFrom).ToList(); DataGridView.Items.Refresh(); Msg = new MessageDialog(Messages.EditMessageTitleBillPeriods, Messages.EditMessageSuccessBillPeriods, MessageDialogButtons.Ok, MessageDialogType.Information, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); ButtonNew_Click(null, null); } catch { Msg = new MessageDialog(Messages.EditMessageTitleBillPeriods, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } } } }
private void ButtonSave_Click(object sender, RoutedEventArgs e) { ControlsValidate?Vd = Commons.ValidateData(FirstControl, ControlsArray); MessageDialog Msg = null; if (Commons.CPeriod.Id > 0 && Commons.CPeriod.IsClosed == false) { if (Vd != null) { Msg = new MessageDialog(Messages.SaveMessageTitleBillsReceivable, Vd.Value.Message, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); Vd.Value.Control.Focus(); } else { if (string.Compare(TextBoxCurrentReadDate.Text.Trim(), Commons.GetCurrentPersianDate()) <= 0) { DomainClasses.SubscriptionsTb MySubscription = CurrentSubscriptionBilling.SubScription; long Price = Convert.ToInt64(TextBoxCurrentRead.Text.Trim()); if (Price > 0) { if (string.Compare(TextBoxCurrentReadDate.Text.Trim(), MySubscription.CurrentReadDate) >= 0) { if (Price != MySubscription.Debt) { Msg = new MessageDialog(Messages.SaveMessageTitleBillsReceivable, Messages.PriceIsNotEqualWithDebt, MessageDialogButtons.YesNo, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); if (Msg.ShowDialog() == false) { TextBoxCurrentRead.SelectAll(); TextBoxCurrentRead.Focus(); return; } } Msg = new MessageDialog(Messages.SaveMessageTitleBillsReceivable, Messages.SaveMessageBillsReceivable, MessageDialogButtons.YesNo, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); if (Msg.ShowDialog() == true) { try { long Deficit1000 = Commons.GetDeficit1000(Price); CurrentSubscriptionBilling.Bill.ReceivableDate = TextBoxCurrentReadDate.Text.Trim(); CurrentSubscriptionBilling.Bill.ReceivablePrice = Price - Deficit1000; CurrentSubscriptionBilling.Bill.ReceivableDefict1000 = Deficit1000; CurrentSubscriptionBilling.Bill.ReceivablePrevDebt = MySubscription.Debt; CurrentSubscriptionBilling.Bill.ReceivablePrevdeficit1000 = MySubscription.deficit1000; if (Price == MySubscription.Debt) { CurrentSubscriptionBilling.Bill.Status = BillsStatus.ReceivableFull; } else { CurrentSubscriptionBilling.Bill.Status = BillsStatus.ReceivableNotMatch; } long OldDebt = MySubscription.Debt, OldDeficit1000 = MySubscription.deficit1000; MySubscription.Debt = MySubscription.Debt - (Price - Deficit1000); MySubscription.deficit1000 = MySubscription.deficit1000 - Deficit1000; Commons.Db.SaveChanges(); SearchAgain = true; Msg = new MessageDialog(Messages.SaveMessageTitleBillsReceivable, Messages.SaveMessageSuccessBillsReceivable, MessageDialogButtons.Ok, MessageDialogType.Information, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); EmptyControl(); TextBoxSubScriptionId.Text = ""; TextBoxSubScriptionId.Focus(); TextBoxSubScriptionId.SelectAll(); } catch { Msg = new MessageDialog(Messages.SaveMessageTitleBillsReceivable, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); TextBoxCurrentRead.SelectAll(); } } } else { Msg = new MessageDialog(Messages.SaveMessageTitleBillsReceivable, Messages.CurrentDateIsNotAllowedLowerThanCurrentReadDate, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); TextBoxCurrentReadDate.Focus(); TextBoxCurrentReadDate.SelectAll(); } } else { Msg = new MessageDialog(Messages.SaveMessageTitleBillsReceivable, Messages.PriceIsNotAllowedZeroOrLess, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); TextBoxCurrentRead.SelectAll(); } } else { Msg = new MessageDialog(Messages.SaveMessageTitleBillsReceivable, Messages.DateIsNotAllowedBiggarThanReceivableDate, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); TextBoxCurrentReadDate.Focus(); TextBoxCurrentReadDate.SelectAll(); } } } else { Msg = new MessageDialog(Messages.SaveMessageTitleBilling, Messages.NotExistPeriodBilling, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); TextBoxCurrentRead.SelectAll(); } }
private void ButtonSave_Click(object sender, RoutedEventArgs e) { ControlsValidate?Vd = Commons.ValidateData(FirstControl, ControlsArray); MessageDialog Msg = null; if (Vd != null) { Msg = new MessageDialog(Messages.SaveMessageTitleSubscriptions, Vd.Value.Message, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); Vd.Value.Control.Focus(); } else { DomainClasses.CustomersTb MyCustomer = Commons.Db.Customers.Find(Convert.ToInt32(TextBoxCustomerId.Text), Commons.CurrentYear); if (MyCustomer == null) { Msg = new MessageDialog(Messages.SaveMessageTitleSubscriptions, Messages.NotFoundCustomers, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); return; } DomainClasses.AccountTypesTb MyAccountType = Commons.Db.AccountTypes.Find(((Int32)((ComboBoxItem)ComboBoxAccountType.SelectedItem).Tag), Commons.CurrentYear); if (MyAccountType == null) { Msg = new MessageDialog(Messages.SaveMessageTitleSubscriptions, Messages.NotFoundAccountTypes, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); return; } DomainClasses.SubscriptionsTb MySubscription = null; MySubscription = Commons.Db.Subscriptions.Find(TextBoxSubScriptionId.Text, Commons.CurrentYear); if (MySubscription == null) { Msg = new MessageDialog(Messages.SaveMessageTitleSubscriptions, Messages.SaveMessageSubscriptions, MessageDialogButtons.YesNo, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); if (Msg.ShowDialog() == true) { try { int?MaxId = Commons.Db.WaterMeters.Where(x => x.Year == Commons.CurrentYear).Max(x => (int?)x.Id); if (MaxId == null) { MaxId = 0; } MaxId++; WaterMetersTb Wm = Commons.Db.WaterMeters.Add(new DomainClasses.WaterMetersTb { Id = Convert.ToInt32(MaxId), SubId = TextBoxSubScriptionId.Text.Trim(), Year = Commons.CurrentYear, ReadStart = Convert.ToInt64(TextBoxWaterMeterNumber.Text.Trim()), ReadDateStart = TextBoxNumberReadDate.Text.Trim(), ReadEnd = Convert.ToInt64(TextBoxWaterMeterNumber.Text.Trim()), ReadDateEnd = TextBoxNumberReadDate.Text.Trim(), WaterMeterSerial = TextBoxWaterMeterSerial.Text.Trim(), Description = "اولین کنتور آب", }); Commons.Db.Subscriptions.Add(new DomainClasses.SubscriptionsTb { Id = TextBoxSubScriptionId.Text.Trim(), Year = Commons.CurrentYear, WaterMeter = Wm, PrevNumber = Convert.ToInt64(TextBoxWaterMeterNumber.Text.Trim()), PrevReadDate = TextBoxNumberReadDate.Text.Trim(), CurrentNumber = Convert.ToInt64(TextBoxWaterMeterNumber.Text.Trim()), CurrentReadDate = TextBoxNumberReadDate.Text.Trim(), Debt = Convert.ToInt64(TextBoxDebt.Text), deficit1000 = Convert.ToInt64(TextBoxDeficit1000.Text), BillingInPeriod = 0, PostalCode = TextBoxPostalCode.Text.Trim(), Address = TextBoxAddress.Text.Trim(), CustomerId = Convert.ToInt32(TextBoxCustomerId.Text.Trim()), CustomerYear = Commons.CurrentYear, AccountTypeId = Convert.ToInt32(((ComboBoxItem)ComboBoxAccountType.SelectedItem).Tag), AccountTypeYear = Commons.CurrentYear, PreventTypeId = Convert.ToInt32(((ComboBoxItem)ComboBoxPreventType.SelectedValue).Tag), PreventTypeYear = Commons.CurrentYear, Description = TextBoxComments.Text.Trim() }); Commons.Db.SaveChanges(); Commons.SetFromEdited("SubScriptions"); SearchAgain = true; DataGridView.Items.Refresh(); Msg = new MessageDialog(Messages.SaveMessageTitleSubscriptions, Messages.SaveMessageSuccessSubscriptions, MessageDialogButtons.Ok, MessageDialogType.Information, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); ButtonNew_Click(null, null); } catch (Exception Ex) { if (Ex.InnerException != null) { if (Ex.InnerException.InnerException != null && Ex.InnerException.InnerException is SqlException) { SqlException SEx = (SqlException)Ex.InnerException.InnerException; if (SEx.Message.Contains("IX_Unique_SubscriptionsTbs_PostalCode")) { Msg = new MessageDialog(Messages.SaveMessageTitleSubscriptions, Messages.PostalCodeIsRepetitive, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); TextBoxPostalCode.Focus(); TextBoxPostalCode.SelectAll(); } } } else { Msg = new MessageDialog(Messages.SaveMessageTitleSubscriptions, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } } } else { Msg = new MessageDialog(Messages.EditMessageTitleSubscriptions, Messages.EditMessageSubscriptions, MessageDialogButtons.YesNo, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); if (Msg.ShowDialog() == true) { try { if (CheckSubscriptionInUse(MySubscription) == false) { //Save When it doesn't have bill WaterMetersTb WmTb = Commons.Db.WaterMeters.Find(MySubscription.WaterMeterId, Commons.CurrentYear); if (WmTb != null) { WmTb.ReadDateStart = TextBoxNumberReadDate.Text.Trim(); WmTb.ReadDateEnd = TextBoxNumberReadDate.Text.Trim(); WmTb.ReadEnd = Convert.ToInt64(TextBoxWaterMeterNumber.Text.Trim()); WmTb.ReadStart = Convert.ToInt64(TextBoxWaterMeterNumber.Text.Trim()); WmTb.WaterMeterSerial = TextBoxWaterMeterSerial.Text.Trim(); } else { Msg = new MessageDialog(Messages.EditMessageTitleSubscriptions, Messages.NotWaterMeterExist, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } MySubscription.PrevNumber = Convert.ToInt64(TextBoxWaterMeterNumber.Text.Trim()); MySubscription.PrevReadDate = TextBoxNumberReadDate.Text.Trim(); MySubscription.CurrentNumber = Convert.ToInt64(TextBoxWaterMeterNumber.Text.Trim()); MySubscription.CurrentReadDate = TextBoxNumberReadDate.Text.Trim(); //MySubscription.Debt = 0; //MySubscription.deficit1000 = 0; } else { Msg = new MessageDialog(Messages.EditMessageTitleSubscriptions, Messages.SubScriptInUseEdit, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } MySubscription.PostalCode = TextBoxPostalCode.Text.Trim(); MySubscription.Address = TextBoxAddress.Text.Trim(); MySubscription.CustomerId = Convert.ToInt32(TextBoxCustomerId.Text.Trim()); MySubscription.AccountTypeId = Convert.ToInt32(((ComboBoxItem)ComboBoxAccountType.SelectedItem).Tag); MySubscription.PreventTypeId = Convert.ToInt32(((ComboBoxItem)ComboBoxPreventType.SelectedValue).Tag); MySubscription.Description = TextBoxComments.Text.Trim(); MySubscription.Debt = Convert.ToInt64(TextBoxDebt.Text); MySubscription.deficit1000 = Convert.ToInt64(TextBoxDeficit1000.Text); Commons.Db.SaveChanges(); Commons.SetFromEdited("SubScriptions"); List <SubscriptionsTb> Lc = (List <SubscriptionsTb>)DataGridView.ItemsSource; if (Lc != null) { SubscriptionsTb Rc = Lc.Find(x => x.Id.Trim() == MySubscription.Id.Trim() && x.Year == Commons.CurrentYear); if (Rc != null) { Rc.AccountType = MySubscription.AccountType; Rc.AccountType = MySubscription.AccountType; Rc.AccountTypeId = MySubscription.AccountTypeId; Rc.AccountTypeYear = MySubscription.AccountTypeYear; Rc.Address = MySubscription.Address; Rc.BillingInPeriod = MySubscription.BillingInPeriod; Rc.CurrentReadDate = MySubscription.CurrentReadDate; Rc.CustomerId = MySubscription.CustomerId; Rc.CustomerYear = MySubscription.CustomerYear; Rc.Debt = MySubscription.Debt; Rc.deficit1000 = MySubscription.deficit1000; Rc.Description = MySubscription.Description; Rc.PostalCode = MySubscription.PostalCode; Rc.PreventTypeId = MySubscription.PreventTypeId; Rc.PreventTypeYear = MySubscription.PreventTypeYear; Rc.PrevNumber = MySubscription.PrevNumber; Rc.PrevReadDate = MySubscription.PrevReadDate; Rc.RecordDate = MySubscription.RecordDate; Rc.WaterMeterId = MySubscription.WaterMeterId; Rc.WaterMeterYear = MySubscription.WaterMeterYear; Rc.Year = MySubscription.Year; } } SearchAgain = true; DataGridView.Items.Refresh(); Msg = new MessageDialog(Messages.EditMessageTitleSubscriptions, Messages.EditMessageSuccessSubscriptions, MessageDialogButtons.Ok, MessageDialogType.Information, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); ButtonNew_Click(null, null); } catch (Exception Ex) { if (Ex.InnerException != null) { if (Ex.InnerException != null) { if (Ex.InnerException.InnerException != null && Ex.InnerException.InnerException is SqlException) { SqlException SEx = (SqlException)Ex.InnerException.InnerException; if (SEx.Message.Contains("IX_Unique_SubscriptionsTbs_PostalCode")) { Msg = new MessageDialog(Messages.SaveMessageTitleSubscriptions, Messages.PostalCodeIsRepetitive, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); TextBoxPostalCode.Focus(); TextBoxPostalCode.SelectAll(); return; } } } } Msg = new MessageDialog(Messages.EditMessageTitleSubscriptions, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } } } } }
private void TextBoxCustomerId_LostFocus(object sender, RoutedEventArgs e) { TextBox text = sender as TextBox; BindingOperations.GetBindingExpression(text, TextBox.TextProperty).UpdateSource(); MessageDialog Msg = null; try { bool IsValid = true; long CId = 0; try { CId = Convert.ToInt64(((TextBox)sender).Text); } catch { IsValid = false; Msg = new MessageDialog(Messages.SearchMessageTitleCustomers, Messages.ForceToCustomersId, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); TextBlockName.Text = ""; TextBlockFamily.Text = ""; TextBlockFather.Text = ""; TextBlockMelicode.Text = ""; TextBlockPostalCode.Text = ""; TextBlockAddress.Text = ""; } if (IsValid == true) { CustomersTb Row = Commons.Db.Customers.Find(CId, Commons.CurrentYear); if (Row != null) { TextBlockName.Text = Row.Name; TextBlockFamily.Text = Row.Family; TextBlockFather.Text = Row.Father; TextBlockMelicode.Text = Row.MeliCode; TextBlockPostalCode.Text = Row.MeliCode; TextBlockAddress.Text = Row.Address; ((ComboBox)((ControlsTab)ControlsArray[sender]).Next).Focus(); ((ComboBox)((ControlsTab)ControlsArray[sender]).Next).IsDropDownOpen = true; } else { Msg = new MessageDialog(Messages.SearchMessageTitleCustomers, Messages.NotFoundCustomers, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); TextBlockName.Text = ""; TextBlockFamily.Text = ""; TextBlockFather.Text = ""; TextBlockMelicode.Text = ""; TextBlockPostalCode.Text = ""; TextBlockAddress.Text = ""; } } } catch { Msg = new MessageDialog(Messages.SearchMessageTitleCustomers, Messages.ErrorSendingDataToDatabase, MessageDialogButtons.Ok, MessageDialogType.Error, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); } }
private void DoSearch() { bool SubScriptionIdFromFlag = true; string SubScriptionIdFromText = ""; bool SubScriptionIdToFlag = true; string SubScriptionIdToText = ""; string NationalCode = ""; bool NationalCodeFlag = true; bool NameFlag = true; string NameText = ""; bool FamilyFlag = true; string FamilyText = ""; bool FatherFlag = true; string FatherText = ""; if (TextBoxSubScriptionIdFrom.Text.Trim() != "") { SubScriptionIdFromFlag = false; string[] Tmp = TextBoxSubScriptionIdFrom.Text.Trim().Split(new char[] { '-' }); if (Tmp != null && Tmp.Length == 2) { SubScriptionIdFromText = Convert.ToInt32(Tmp[0]).ToString("0000") + "-" + Convert.ToInt32(Tmp[1]).ToString("00000"); } else { MessageDialog Msg = new MessageDialog(Messages.PrintMessageTitleSubScription, Messages.ValueIsSubscriptionNumberStart + "از شماره اشتراک" + Messages.ValueIsSubscriptionNumberEnd, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); return; } //Sql = "SubscriptionId='" + TextBoxSubScriptionId.Text.Trim() + "'"; } if (TextBoxSubScriptionIdTo.Text.Trim() != "") { SubScriptionIdToFlag = false; string[] Tmp = TextBoxSubScriptionIdTo.Text.Trim().Split(new char[] { '-' }); if (Tmp != null && Tmp.Length == 2) { SubScriptionIdToText = Convert.ToInt32(Tmp[0]).ToString("0000") + "-" + Convert.ToInt32(Tmp[1]).ToString("00000"); } else { MessageDialog Msg = new MessageDialog(Messages.PrintMessageTitleSubScription, Messages.ValueIsSubscriptionNumberStart + "تا شماره اشتراک" + Messages.ValueIsSubscriptionNumberEnd, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); return; } //Sql = "SubscriptionId='" + TextBoxSubScriptionId.Text.Trim() + "'"; } if (TextBoxName.Text.Trim() != "") { NameFlag = false; NameText = TextBoxName.Text.Trim(); //if (Sql.Trim() != "") // Sql += " AND Name like N'%" + TextBoxName.Text.Trim() + "%'"; //else // Sql += " Name like N'%" + TextBoxName.Text.Trim() + "%'"; } if (TextBoxFamily.Text.Trim() != "") { FamilyFlag = false; FamilyText = TextBoxFamily.Text.Trim(); //if (Sql.Trim() != "") // Sql += " AND Family like N'%" + TextBoxFamily.Text.Trim() + "%'"; //else // Sql += " Family like N'%" + TextBoxFamily.Text.Trim() + "%'"; } if (TextBoxFather.Text.Trim() != "") { FatherFlag = false; FatherText = TextBoxFather.Text.Trim(); //if (Sql.Trim() != "") // Sql += " AND Father like N'%" + TextBoxFather.Text.Trim() + "%'"; //else // Sql += " Father like N'%" + TextBoxFather.Text.Trim() + "%'"; } if (TextBoxMeliCode.Text.Trim() != "") { NationalCodeFlag = false; NationalCode = TextBoxMeliCode.Text.Trim(); //if (Sql.Trim() != "") // Sql += " AND MeliCode = " + TextBoxMeliCode.Text.Trim(); //else // Sql += " MeliCode = " + TextBoxMeliCode.Text.Trim(); } if (SubScriptionIdFromFlag || SubScriptionIdToFlag || NameFlag || FamilyFlag || FatherFlag || NationalCodeFlag) { DataGridView.ItemsSource = Commons.Db.Subscriptions.Include(x => x.Customer).Include(x => x.AccountType).Where(x => x.Year == Commons.CurrentYear && (NameFlag == true || x.Customer.Name.Contains(NameText)) && (FamilyFlag == true || x.Customer.Family.Contains(FamilyText)) && (FatherFlag == true || x.Customer.Father.Contains(FatherText)) && (NationalCodeFlag == true || x.Customer.MeliCode == NationalCode)) .ToList() .Where(x => (SubScriptionIdFromFlag == true || x.SortableId.CompareTo(SubScriptionIdFromText) >= 0) && (SubScriptionIdToFlag == true || x.SortableId.CompareTo(SubScriptionIdToText) <= 0)).OrderBy(x => x.SortableId).ToList(); } }
private void DoSearch() { string Sql = ""; bool SubScriptionIdFromFlag = true; string SubScriptionIdFromText = ""; bool SubScriptionIdToFlag = true; string SubScriptionIdToText = ""; bool NameFlag = true; string NameText = ""; bool FamilyFlag = true; string FamilyText = ""; bool FatherFlag = true; string FatherText = ""; bool CellphoneFlag = true; string Cellphone = ""; string NationalCode = ""; bool NationalCodeFlag = true; if (TextBoxSubScriptionIdFrom.Text.Trim() != "") { SubScriptionIdFromFlag = false; string[] Tmp = TextBoxSubScriptionIdFrom.Text.Trim().Split(new char[] { '-' }); if (Tmp != null && Tmp.Length == 2) { SubScriptionIdFromText = Convert.ToInt32(Tmp[0]).ToString("0000") + "-" + Convert.ToInt32(Tmp[1]).ToString("00000"); } else { MessageDialog Msg = new MessageDialog(Messages.PrintMessageTitleSubScription, Messages.ValueIsSubscriptionNumberStart + "از شماره اشتراک" + Messages.ValueIsSubscriptionNumberEnd, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); return; } } if (TextBoxSubScriptionIdTo.Text.Trim() != "") { SubScriptionIdToFlag = false; string[] Tmp = TextBoxSubScriptionIdTo.Text.Trim().Split(new char[] { '-' }); if (Tmp != null && Tmp.Length == 2) { SubScriptionIdToText = Convert.ToInt32(Tmp[0]).ToString("0000") + "-" + Convert.ToInt32(Tmp[1]).ToString("00000"); } else { MessageDialog Msg = new MessageDialog(Messages.PrintMessageTitleSubScription, Messages.ValueIsSubscriptionNumberStart + "تا شماره اشتراک" + Messages.ValueIsSubscriptionNumberEnd, MessageDialogButtons.Ok, MessageDialogType.Warning, GridHeader.Background); Msg.Owner = Window.GetWindow(this); Msg.ShowDialog(); return; } } if (TextBoxName.Text.Trim() != "") { NameFlag = false; NameText = TextBoxName.Text.Trim(); } if (TextBoxFamily.Text.Trim() != "") { FamilyFlag = false; FamilyText = TextBoxFamily.Text.Trim(); } if (TextBoxFather.Text.Trim() != "") { FatherFlag = false; FatherText = TextBoxFather.Text.Trim(); } if (TextBoxMeliCode.Text.Trim() != "") { NationalCodeFlag = false; NationalCode = TextBoxMeliCode.Text.Trim(); } if (TextBoxCellPhone.Text.Trim() != "") { CellphoneFlag = false; Cellphone = TextBoxCellPhone.Text.Trim(); } if (SubScriptionIdFromFlag || SubScriptionIdToFlag || NameFlag || FamilyFlag || FatherFlag || NationalCodeFlag) { DataGridView.ItemsSource = Commons.Db.BillsVws.AsNoTracking().ToList().Where( x => (SubScriptionIdFromFlag == true || x.SortableId.CompareTo(SubScriptionIdFromText) >= 0) && (SubScriptionIdToFlag == true || x.SortableId.CompareTo(SubScriptionIdToText) <= 0) && (NameFlag == true || x.Name.Contains(NameText)) && (FamilyFlag == true || x.Family.Contains(FamilyText)) && (FatherFlag == true || x.Father.Contains(FatherText)) && (NationalCodeFlag == true || x.MeliCode == NationalCode) && (CellphoneFlag == true || x.CellPhone == Cellphone) && x.Debt > 0).OrderBy(x => x.SortableId); } }