private void Fillfields(DataTable LadBillCreditDataTable) { if (LadBillCreditDataTable != null && LadBillCreditDataTable.Rows.Count > 0) { LadBillCreditDataTable.Columns.Add("WaitingDay"); foreach (DataRow row in LadBillCreditDataTable.Rows) { Hepsa.Core.Common.MyDateTime TurnDate = new Hepsa.Core.Common.MyDateTime(row["TurnDate_nvc"].ToString()); string GeorgianTurnDate = TurnDate.MyDate.ToString("yyyy/MM/dd");// +" " + row["TurnTime_nvc"].ToString(); DateTime TurnDateTime = DateTime.Parse(GeorgianTurnDate); Hepsa.Core.Common.MyDateTime LadBillDate = new Hepsa.Core.Common.MyDateTime(row["LadBillDate_nvc"].ToString()); string GeorgianLadBillDate = LadBillDate.MyDate.ToString("yyyy/MM/dd");// +" " + row["LadBillTime_nvc"].ToString(); DateTime LadBillDateTime = DateTime.Parse(GeorgianLadBillDate); TimeSpan WaitindDayTimeSpan = LadBillDateTime.Subtract(TurnDateTime); int WaitindDay = WaitindDayTimeSpan.Days; row["WaitingDay"] = WaitindDay; } this.DataSource = LadBillCreditDataTable; this.LadBillCreditDatetxt.DataField = "LadBillDate_nvc"; LadBillCreditTimetxt.DataField = "LadBillTime_nvc"; LadBillNumbertxt.DataField = "LadBillCreditID_int"; TurnNumbertxt.DataField = "AcceptedTurnNumber_bint"; LaderTypetxt.DataField = "LaderTypeID_intLaderType_nvc"; CarNumbertxt.DataField = "NumberPlate"; CarCardNumbertxt.DataField = "CarCardNumber_nvc"; DriverCardNumbertxt.DataField = "DriverCardNumber_nvc"; Companytxt.DataField = "CompanyID_intCompany_nvc"; Goodtxt.DataField = "GoodID_intGood_nvc"; PortPlacetxt.DataField = "PortPlaceID_intPortPlaces_nvc"; Citytxt.DataField = "CityID_intCity_nvc"; Commenttxt.DataField = "Comment_nvc"; Usertxt.DataField = "LBUser"; Pricetxt.DataField = "PortageFee_dec"; TurnDatetxt.DataField = "TurnDate_nvc"; TurnHourtxt.DataField = "TurnTime_nvc"; DriverNametxt.DataField = "DriverName"; WaitingDaytxt.DataField = "WaitingDay"; UserNameTextBox.Text = HPS.Common.CurrentUser.user.UserName_nvc; Int64?AllRequestCountRecords = LadBillCreditDataTable.Rows.Count; AllCounttextBox.Text = AllRequestCountRecords.HasValue ? AllRequestCountRecords.ToString() : "0"; } }
private void ShowButton_Click(object sender, EventArgs e) { try { string Condition = string.Empty; Properties.Settings Setting = new HPS.Properties.Settings(); Int32?SaloonID_int = null; if (Setting.SaloonID_int != 0) { SaloonID_int = Setting.SaloonID_int; } HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TFactory LadeAssignmentFactory = new HPS.BLL.LadeAssignmentBLL.BLLLadeAssignment_TFactory(); DataTable LadeAssignmentDataTable = new DataTable(); if (string.IsNullOrEmpty(LadeAssingmentID_binttextBox.Text)) { if (!FromDatefaDatePicker.IsNull) { Hepsa.Core.Validation.DateRule <string> FromDateValidator = new Hepsa.Core.Validation.DateRule <string>("FromDate", "از تاریخ", null, null); if (FromDateValidator.Validate(FromDatefaDatePicker.Text) == false) { throw new ApplicationException(FromDateValidator.Description); } else { DateTime MiladiCurrentDate = LadeAssignmentFactory.ServerDate.AddDays(-30); Hepsa.Core.Common.MyDateTime OneMonthBeforeCurrentDate = new Hepsa.Core.Common.MyDateTime(MiladiCurrentDate); if (FromDatefaDatePicker.Text.CompareTo(OneMonthBeforeCurrentDate.ConvertToPersianShortDate()) < 0) { throw new ApplicationException("تاریخ شروع نمی تواند کمتر از یک ماه اخیر باشد"); } Condition = string.Format("Date_nvc >= '{0}'", FromDatefaDatePicker.Text); } } if (!ToDatefaDatePicker.IsNull) { Hepsa.Core.Validation.DateRule <string> ToDateValidator = new Hepsa.Core.Validation.DateRule <string>("ToDate", "تا تاریخ", null, null); if (ToDateValidator.Validate(ToDatefaDatePicker.Text) == false) { throw new ApplicationException(ToDateValidator.Description); } else { Condition = string.Format(" {0} And Date_nvc <='{1}'", Condition, ToDatefaDatePicker.Text); } } if (HPS.Common.CurrentUser.user.CompanyID_int != null) { Condition = string.Format("{0} And CompanyID_int = {1}", Condition, HPS.Common.CurrentUser.user.CompanyID_int); } if (this.LaderTypeID_intComboBox.SelectedIndex != -1) { Condition = string.Format("{0} And LaderTypeID = {1}", Condition, LaderTypeID_intComboBox.SelectedValue.ToString()); } if (GoodID_intcomboBox.SelectedIndex != -1) { Condition = string.Format("{0} And GoodID_int = {1}", Condition, GoodID_intcomboBox.SelectedValue.ToString()); } if (PortPlaceID_intcomboBox.SelectedIndex != -1) { Condition = string.Format("{0} And PortPlaceID_int = {1}", Condition, PortPlaceID_intcomboBox.SelectedValue.ToString()); } if (DestinationCityID_intcomboBox.SelectedIndex != -1) { Condition = string.Format("{0} And CityID_int = {1} ", Condition, DestinationCityID_intcomboBox.SelectedValue.ToString()); } if (Condition.Length > 0) { if (Condition.Substring(0, 4) == " And") { Condition = Condition.Substring(4, Condition.Length - 4); } } } else { DestinationCityID_intcomboBox.SelectedIndex = -1; PortPlaceID_intcomboBox.SelectedIndex = -1; GoodID_intcomboBox.SelectedIndex = -1; LaderTypeID_intComboBox.SelectedIndex = -1; this.FromDatefaDatePicker.IsNull = true; this.ToDatefaDatePicker.IsNull = true; if (HPS.Common.CurrentUser.user.CompanyID_int != null) { Condition = string.Format("CompanyID_int = {0} and ", HPS.Common.CurrentUser.user.CompanyID_int); } Condition += string.Format(" LadeAssignmentID_bint = {0} ", LadeAssingmentID_binttextBox.Text); } LadeAssignmentFactory.GetAllByCondition(Condition, SaloonID_int, ref LadeAssignmentDataTable); this.LadeAssignmentGridView.AutoGenerateColumns = false; this.LadeAssignmentGridView.DataSource = LadeAssignmentDataTable; } catch (Exception ex) { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); } }
private Int32 DoCancelOperation(string Date_nvc, string LaderTypeID_nvc) { string CancelDate = string.Empty; if (string.IsNullOrEmpty(Date_nvc)) { HPS.BLL.SettingsBLL.BLLSetting_TFactory SettingFactory = new HPS.BLL.SettingsBLL.BLLSetting_TFactory(); HPS.BLL.SettingsBLL.BLLSetting_T SettingEntity = new HPS.BLL.SettingsBLL.BLLSetting_T(); HPS.BLL.SettingsBLL.BLLSetting_TKeys SettingKey = new HPS.BLL.SettingsBLL.BLLSetting_TKeys(); SettingKey.SettingID_int = 1003; SettingEntity = SettingFactory.GetBy(SettingKey); Hepsa.Core.Common.MyDateTime CurrentDate = new Hepsa.Core.Common.MyDateTime(SettingFactory.ServerJalaliDate); string CancelTime = SettingFactory.ServerTime; string CurrentDateTime = CurrentDate.MyDate.ToString("yyyy/MM/dd") + " " + CancelTime; DateTime SubtractedDate = DateTime.Parse(CurrentDateTime); SubtractedDate = SubtractedDate.AddHours(-Int32.Parse(SettingEntity.Value_nvc)); CancelDate = new Hepsa.Core.Common.MyDateTime(SubtractedDate).ConvertToPersianShortDate(); } else { CancelDate = Date_nvc; } HPS.BLL.TurnCancelCommentBLL.BLLTurnCancelComment_TFactory TurnCancelCommentFactory = new HPS.BLL.TurnCancelCommentBLL.BLLTurnCancelComment_TFactory(); HPS.BLL.TurnCancelCommentBLL.BLLTurnCancelComment_T TurnCancelCommentEntity = new HPS.BLL.TurnCancelCommentBLL.BLLTurnCancelComment_T(); HPS.BLL.TurnCancelCommentBLL.BLLTurnCancelComment_TKeys TurnCancelCommentKey = new HPS.BLL.TurnCancelCommentBLL.BLLTurnCancelComment_TKeys(); TurnCancelCommentKey.TurnCancelCommentID_int = 40; TurnCancelCommentEntity = TurnCancelCommentFactory.GetBy(TurnCancelCommentKey); HPS.BLL.TurnManagementBLL.BLLTurnManagement_TFactory TurnManagementFactory = new HPS.BLL.TurnManagementBLL.BLLTurnManagement_TFactory(); HPS.BLL.TrafficBLL.BLLTraffic_TFactory TrafficFactory = new HPS.BLL.TrafficBLL.BLLTraffic_TFactory(); DataTable AcceptedTurnsWithoutLadBillDataTable = new DataTable(); if (string.IsNullOrEmpty(LaderTypeID_nvc)) { TrafficFactory.SelectInTurnAcceptedForDelete(CancelDate, string.Empty, AcceptedTurnsWithoutLadBillDataTable); } else { TrafficFactory.SelectInTurnAcceptedForDelete(CancelDate, LaderTypeID_nvc, AcceptedTurnsWithoutLadBillDataTable); } int rowcount = -1; if (AcceptedTurnsWithoutLadBillDataTable != null && AcceptedTurnsWithoutLadBillDataTable.Rows.Count > 0) { rowcount = AcceptedTurnsWithoutLadBillDataTable.Rows.Count; foreach (DataRow row in AcceptedTurnsWithoutLadBillDataTable.Rows) { HPS.BLL.TurnManagementBLL.BLLTurnManagement_T TurnManagementEntity = new HPS.BLL.TurnManagementBLL.BLLTurnManagement_T(); TurnManagementEntity.TurnCancelCommantID_int = TurnCancelCommentEntity.TurnCancelCommentID_int; TurnManagementEntity.TurnCancelCommment_nvc = TurnCancelCommentEntity.TurnCancelComment_nvc; TurnManagementEntity.Return_bit = false; TurnManagementEntity.Date_nvc = TurnManagementFactory.ServerJalaliDate; TurnManagementEntity.Time_nvc = TurnManagementFactory.ServerTime; TurnManagementEntity.UserName_nvc = HPS.Common.CurrentUser.user.UserName_nvc; TurnManagementEntity.TrafficID_bint = Convert.ToInt64(row["TrafficID_bint"]); TurnManagementFactory.BeginProc(); TurnManagementFactory.Insert(TurnManagementEntity); TurnManagementFactory.CommitProc(); } } return(rowcount); }
public IranianInNotOutTrafficReport(string FromDate, string ToDate, int TrafficType, int?PivotGroupID, int?ServicesID) { // // Required for Windows Form Designer support // InitializeComponent(); FromDatetxt.Text = FromDate; ToDatetxt.Text = ToDate; HPS.BLL.TrafficBLL.BLLTraffic_TFactory TrafficFactory = new HPS.BLL.TrafficBLL.BLLTraffic_TFactory(); DataTable TrafficDataTable = new DataTable(); string Condition = string.Empty; if (ServicesID.HasValue) { if (PivotGroupID.HasValue) { Condition = String.Format("(T1.TrafficTypeID_int='1') AND (T1.Date_nvc>='{0}') AND (T1.Date_nvc<='{1}') AND (LaderPivotGroup_T.LaderPivotGroupID_int={2}) AND (T1.ServiceID_int={3})", FromDate, ToDate, PivotGroupID, ServicesID); } else { Condition = String.Format("(T1.TrafficTypeID_int='1') AND (T1.Date_nvc>='{0}') AND (T1.Date_nvc<='{1}') AND (T1.ServiceID_int={2})", FromDate, ToDate, ServicesID); } } else { if (PivotGroupID.HasValue) { Condition = String.Format("(T1.TrafficTypeID_int='1') AND (T1.Date_nvc>='{0}') AND (T1.Date_nvc<='{1}') AND (LaderPivotGroup_T.LaderPivotGroupID_int={2})", FromDate, ToDate, PivotGroupID); } else { Condition = String.Format("(T1.TrafficTypeID_int='1') AND (T1.Date_nvc>='{0}') AND (T1.Date_nvc<='{1}')", FromDate, ToDate); } } TrafficFactory.GetAllByConditionAllInTrafficNotTemporaryOut(Condition, ref TrafficDataTable); TrafficDataTable.Columns.Add(new DataColumn("AllPayment_dec", typeof(decimal))); TrafficDataTable.Columns.Add(new DataColumn("Remained_dec", typeof(decimal))); HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory LaderTypeFactory = new HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory(); HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys LaderTypeKey = new HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys(); string stopFeeCondition = string.Empty; var stopFeeFactory = new BLL.StopFeeBLL.BLLStopFee_TFactory(); BLL.StopFeeBLL.BLLStopFee_T oldStopFeeEntity = null; BLL.StopFeeBLL.BLLStopFee_TKeys stopFeeKey = null; BLL.LaderTypeBLL.BLLLaderType_T laderTypeEntity = null; HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TFactory LadBillFactory = new HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TFactory(); DataTable TrafficInWithladBillDataTable = null; DataTable TrafficInDatatable = null; HPS.BLL.SettingsBLL.BLLSetting_TFactory settingsFactory = new HPS.BLL.SettingsBLL.BLLSetting_TFactory(); HPS.BLL.SettingsBLL.BLLSetting_TKeys SettingKey = null; HPS.BLL.SettingsBLL.BLLSetting_T TurnHourSettingEntity = null; HPS.BLL.SettingsBLL.BLLSetting_T SettingEntity = null; foreach (DataRow row in TrafficDataTable.Rows) { DataTable LaderTypeDataTable = new DataTable(); try { oldStopFeeEntity = new BLL.StopFeeBLL.BLLStopFee_T(); stopFeeKey = new BLL.StopFeeBLL.BLLStopFee_TKeys(); stopFeeKey.StopFeeID_int = Convert.ToInt32(row["StopFeeID_int"]); oldStopFeeEntity = stopFeeFactory.GetBy(stopFeeKey); if ((Int32)row["TrafficTypeID_int"] == 1) { laderTypeEntity = new BLL.LaderTypeBLL.BLLLaderType_T(); LaderTypeKey.LaderTypeID_int = Convert.ToInt32(row["LaderTypeID_int"]); laderTypeEntity = LaderTypeFactory.GetBy(LaderTypeKey); stopFeeCondition = string.Format(" StartDate_nvc>'{0}' AND StopFee_T.TrafficTypeID_int={1} AND StopFee_T.ServicesID_int={2} AND StopFee_T.LaderPivotGroupID_int={3}", oldStopFeeEntity.EndDate_nvc, Convert.ToInt32(row["TrafficTypeID_int"]), Convert.ToInt32(row["ServiceID_int"]), laderTypeEntity.LaderPivotGroupID_int); } else { stopFeeCondition = string.Format(" StartDate_nvc>'{0}' AND StopFee_T.TrafficTypeID_int={1}", oldStopFeeEntity.StartDate_nvc, Convert.ToInt32(row["TrafficTypeID_int"])); } var newStopFeeTable = new DataTable(); stopFeeFactory.GetAllByCondition(stopFeeCondition, ref newStopFeeTable); Hepsa.Core.Common.MyDateTime InDateTime = new Hepsa.Core.Common.MyDateTime(row["Date_nvc"].ToString()); Hepsa.Core.Common.MyDateTime OutDateTime = new Hepsa.Core.Common.MyDateTime(TrafficFactory.ServerJalaliDate); string InDate = InDateTime.MyDate.ToString("yyyy/MM/dd"); //+ " " + InTime_nvcTextBox.Text; string OutDate = OutDateTime.MyDate.ToString("yyyy/MM/dd"); // + " " + Time_nvcTextBox.Text; if (InDate.Length == 16) { InDate += ":00"; } else if (InDate.Length > 19) { InDate = InDate.Substring(0, 19); } if (OutDate.Length == 16) { OutDate += ":00"; } else if (OutDate.Length > 19) { OutDate = OutDate.Substring(0, 19); } decimal Price = Convert.ToDecimal(row["Fee_dec"]); if (Convert.ToInt32(row["ServiceID_int"]) == 2) { Price = row["Fee_dec"] != null?Convert.ToInt32(row["Fee_dec"]) : 0; } string incondition = "Traffic_T.TrafficNumber_bint='" + row["TrafficNumber_bint"].ToString() + "'"; Condition = string.Format("Traffic_T.TurnNumber_bint='{0}' And Traffic_T.TrafficNumber_bint<>{1}", row["TurnNumber_bint"], row["TrafficNumber_bint"].ToString()); TrafficInWithladBillDataTable = new DataTable(); LadBillFactory.GetAllWithTrafficLadBillCreditByConditon(incondition, ref TrafficInWithladBillDataTable); TrafficInDatatable = new DataTable(); TrafficFactory.GetAllByCondition(Condition, ref TrafficInDatatable); SettingKey = new HPS.BLL.SettingsBLL.BLLSetting_TKeys(); SettingKey.SettingID_int = 1002; TurnHourSettingEntity = settingsFactory.GetBy(SettingKey); if (TrafficInDatatable.Rows.Count > 0) { DateTime TrafficDate = DateTime.Parse((new Hepsa.Core.Common.MyDateTime(TrafficInDatatable.Rows[0]["Date_nvc"].ToString())).MyDate.ToString("yyyy/MM/dd") + " " + TrafficInDatatable.Rows[0]["Time_nvc"].ToString()); Int32 Allowablehour = Convert.ToInt32(TurnHourSettingEntity.Value_nvc); if (TrafficFactory.ServerDate <= TrafficDate.AddHours(Allowablehour)) { if (TrafficInWithladBillDataTable.Rows.Count == 0) { Price = 0; } } } decimal Balanced = 0; TimeSpan ts = new TimeSpan(); if (newStopFeeTable != null && newStopFeeTable.Rows.Count > 0) { //Hepsa.Core.Common.MyDateTime stopFeeMiladiEndDate_nvc = new Hepsa.Core.Common.MyDateTime(newStopFeeTable.Rows[0]["EndDate_nvc"].ToString()); //string stopFeeEndDate_nvc = stopFeeMiladiEndDate_nvc.MyDate.ToString("yyyy/MM/dd"); Hepsa.Core.Common.MyDateTime stopFeeMiladiEndDate_nvc = new Hepsa.Core.Common.MyDateTime(oldStopFeeEntity.EndDate_nvc); string stopFeeEndDate_nvc = stopFeeMiladiEndDate_nvc.MyDate.ToString("yyyy/MM/dd"); ts = DateTime.Parse(stopFeeEndDate_nvc).Subtract(DateTime.Parse(InDate)); if (Convert.ToBoolean(row["TurnAccepted_bit"]) == true) { double ExtraHour = ts.TotalHours; SettingEntity = new HPS.BLL.SettingsBLL.BLLSetting_T(); SettingKey.SettingID_int = 1002; SettingEntity = settingsFactory.GetBy(SettingKey); ExtraHour -= Convert.ToDouble(SettingEntity.Value_nvc); if (ExtraHour > 0) { ///محاسبه مازاد بر اساس قیمت قبلی از ورود تا شروع قیمت جدید int days = (int)(ExtraHour / Convert.ToInt32(row["ExtraHour_int"])); Price += Math.Floor(((decimal)(days)) * Convert.ToDecimal(row["ExtraHourFee_dec"])); } Hepsa.Core.Common.MyDateTime stopFeeMiladiStartDate_nvc = new Hepsa.Core.Common.MyDateTime(newStopFeeTable.Rows[0]["StartDate_nvc"].ToString()); string newStopFeeStartDate_nvc = stopFeeMiladiStartDate_nvc.MyDate.ToString("yyyy/MM/dd"); TimeSpan ExtaTS = DateTime.Parse(newStopFeeStartDate_nvc).Subtract(DateTime.Parse(InDate)); double ExtraExtraHour = ExtaTS.TotalHours; if (ExtraExtraHour < Convert.ToDouble(SettingEntity.Value_nvc)) { ///محاسبه مازاد از شروع تاریخ قیمت جدید تا تاریخ خروج if (ExtraHour >= 0) { ts = DateTime.Parse(OutDate).AddDays(1).Subtract(DateTime.Parse(InDate)); } else { ts = DateTime.Parse(OutDate).Subtract(DateTime.Parse(InDate)); } ExtraHour = ts.TotalHours - Convert.ToDouble(SettingEntity.Value_nvc); if (ExtraHour >= 0) { Int32 days = Convert.ToInt32((ExtraHour / Convert.ToInt32(newStopFeeTable.Rows[0]["ExtraHour_int"]))); Price += Math.Floor((Convert.ToDecimal((days)) * Convert.ToDecimal(newStopFeeTable.Rows[0]["ExtraHourFee_dec"]))); } } else { ///محاسبه مازاد از شروع تاریخ قیمت جدید تا تاریخ خروج //Hepsa.Core.Common.MyDateTime stopFeeMiladiStartDate_nvc = new Hepsa.Core.Common.MyDateTime(newStopFeeTable.Rows[0]["StartDate_nvc"].ToString()); //string newStopFeeStartDate_nvc = stopFeeMiladiStartDate_nvc.MyDate.ToString("yyyy/MM/dd"); //ts = DateTime.Parse(OutDate).AddDays(1).Subtract(DateTime.Parse(newStopFeeStartDate_nvc)); if (ExtraHour > 0) { ts = DateTime.Parse(OutDate).AddDays(1).Subtract(DateTime.Parse(newStopFeeStartDate_nvc)); } else { ts = DateTime.Parse(OutDate).Subtract(DateTime.Parse(newStopFeeStartDate_nvc)); } ExtraHour = ts.TotalHours; if (ExtraHour > 0) { Int32 days = Convert.ToInt32((ExtraHour / Convert.ToInt32(newStopFeeTable.Rows[0]["ExtraHour_int"]))); Price += Math.Floor((Convert.ToDecimal((days)) * Convert.ToDecimal(newStopFeeTable.Rows[0]["ExtraHourFee_dec"]))); } } } else { if (Convert.ToDecimal(row["ExtraHourFee_dec"]) != 0) { ///محاسبه مازاد بر اساس قیمت قبلی از ورود تا شروع قیمت جدید double ExtraHour = ts.TotalHours - Convert.ToDouble(row["AllowableHour_int"]); int days = Convert.ToInt32((ExtraHour / Convert.ToInt32(row["ExtraHour_int"]))); Price += Math.Floor(((decimal)(days)) * Convert.ToDecimal(row["ExtraHourFee_dec"])); ///محاسبه مازاد از شروع تاریخ قیمت جدید تا تاریخ خروج Hepsa.Core.Common.MyDateTime stopFeeMiladiStartDate_nvc = new Hepsa.Core.Common.MyDateTime(newStopFeeTable.Rows[0]["StartDate_nvc"].ToString()); string newStopFeeStartDate_nvc = stopFeeMiladiStartDate_nvc.MyDate.ToString("yyyy/MM/dd"); ts = DateTime.Parse(OutDate).AddDays(1).Subtract(DateTime.Parse(newStopFeeStartDate_nvc)); ExtraHour = ts.TotalHours; days = (int)(ExtraHour / (int)newStopFeeTable.Rows[0]["ExtraHour_int"]); Price += Math.Floor(((decimal)(days)) * Convert.ToDecimal(newStopFeeTable.Rows[0]["ExtraHourFee_dec"])); } } } else { ts = DateTime.Parse(OutDate).Subtract(DateTime.Parse(InDate)); if (ts.TotalHours > Convert.ToInt32(row["AllowableHour_int"])) { if (Convert.ToBoolean(row["TurnAccepted_bit"]) == true) { double ExtraHour = ts.TotalHours; SettingEntity = new BLL.SettingsBLL.BLLSetting_T(); SettingKey.SettingID_int = 1002; SettingEntity = settingsFactory.GetBy(SettingKey); ExtraHour -= Convert.ToDouble(SettingEntity.Value_nvc); if (ExtraHour > 0) { int days = (int)(ExtraHour / Convert.ToInt32(row["ExtraHour_int"])); Price += Math.Floor(((decimal)(days)) * Convert.ToDecimal(row["ExtraHourFee_dec"])); } //else //{ // Price = 0; //} } else { if (Convert.ToDecimal(row["ExtraHourFee_dec"]) != 0) { double ExtraHour = ts.TotalHours - Convert.ToDouble(row["AllowableHour_int"]); int days = (int)(ExtraHour / Convert.ToInt32(row["ExtraHour_int"])); Price += Math.Floor(((decimal)(days)) * Convert.ToDecimal(row["ExtraHourFee_dec"])); } } } } row["AllPayment_dec"] = Convert.ToString(Price);//+ Balanced if (Price == Balanced) { row["Remained_dec"] = "0"; } else { row["Remained_dec"] = Price - Convert.ToDecimal(row["Price_dec"]);// } if ((Price - Balanced) < 0) { row["Remained_dec"] = Convert.ToDecimal(row["Price_dec"]); } } catch (Exception ex) { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); } } //AllPayment_dec DataSource = TrafficDataTable; Datetxt.DataField = "Date_nvc"; Timetxt.DataField = "Time_nvc"; TurnNumbertxt.DataField = "TurnNumber_bint"; TrafficNumbertxt.DataField = "TrafficNumber_bint"; NumberPlateTextBox.DataField = "NumberPlate_nvc"; PlateCitytxt.DataField = "PlateCityID_intPlateCity_nvc"; SerialPlateTextBox.DataField = "SerialPlate_nvc"; CarCardNumbertxt.DataField = "CarCardNumber_nvc"; DriverCardNumbertxt.DataField = "DriverCardNumber_nvc"; Pricetxt.DataField = "Price_dec"; Usertxt.DataField = "UserName_nvc"; LastNametxt.DataField = "FullName_nvc"; TurnAcceptedchk.DataField = "TurnAccepted_bit"; ServiceType_nvctxt.DataField = "ServiceID_intServiceType_nvc"; DriverCardNumbertxt.DataField = "DriverInfraction_nvc"; CarInfractiontxt.DataField = "CarInfraction_nvc"; payment_dectxt.DataField = "AllPayment_dec"; remained_dectxt.DataField = "Remained_dec"; DateTextBox.Text = TrafficFactory.ServerJalaliDate; TimeTextBox.Text = TrafficFactory.ServerTime; UserNameTextBox.Text = HPS.Common.CurrentUser.user.UserName_nvc; decimal?AllPrice = (from row in TrafficDataTable.AsEnumerable() select(decimal?) row["Price_dec"]).Sum(); AllPricetxt.Text = AllPrice.HasValue ? AllPrice.ToString() : "0"; decimal?AllPayment_dec = (from row in TrafficDataTable.AsEnumerable() select(decimal?) row["AllPayment_dec"]).Sum(); allPayment_dectxt.Text = AllPayment_dec.HasValue ? AllPayment_dec.ToString() : "0"; decimal?AllRemained_dec = (from row in TrafficDataTable.AsEnumerable() select(decimal?) row["Remained_dec"]).Sum(); allRemained_dectxt.Text = AllRemained_dec.HasValue ? AllRemained_dec.ToString() : "0"; }