예제 #1
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            if (LaderTypeGridView.CurrentRow != null)
            {
                HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory LaderTypeFactory = new HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory();
                HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys    LaderTypeKey     = new HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys();
                LaderTypeKey.LaderTypeID_int = (Int32)LaderTypeGridView.CurrentRow.Cells[colLaderTypeID_int.Name].Value;
                LaderTypeEntity = LaderTypeFactory.GetBy(LaderTypeKey);

                if (string.IsNullOrEmpty(Hepsa.Core.Common.PersentationController.GetEntityValue(LaderTypeGridView.CurrentRow.Cells[colLaderTypeID_int.Name].Value, TypeCode.String).ToString()) == false)
                {
                    LaderTypeEntity.LaderType_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(LaderTypeGridView.CurrentRow.Cells[colLaderType_nvc.Name].Value, TypeCode.String).ToString();
                }
            }
            this.Close();
        }
예제 #2
0
 protected override void ShowForm()
 {
     this.FillCombo();
     HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory LaderTypeFactory = new HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory();
     HPS.BLL.LaderTypeBLL.BLLLaderType_T        LaderTypeEntity  = LaderTypeFactory.GetBy((HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys)Key);
     if (LaderTypeEntity == null)
     {
         throw new HPS.Exceptions.LaderTypeNotFound();
     }
     LaderTypeCode_nvcTextBox.Text         = Hepsa.Core.Common.PersentationController.GetEntityValue(LaderTypeEntity.LaderTypeCode_nvc, TypeCode.String).ToString();
     LaderType_nvcTextBox.Text             = Hepsa.Core.Common.PersentationController.GetEntityValue(LaderTypeEntity.LaderType_nvc, TypeCode.String).ToString();
     MinTruckWeight_decNumericTextBox.Text = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(LaderTypeEntity.MinTruckWeight_dec, TypeCode.Decimal));
     MaxTruckWeight_decNumericTextBox.Text = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(LaderTypeEntity.MaxTruckWeight_dec, TypeCode.Decimal));
     Active_bitCheckBox.Checked            = (Boolean)Hepsa.Core.Common.PersentationController.GetEntityValue(LaderTypeEntity.Active_bit, TypeCode.Boolean);
     Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref LaderPivotGroupID_intComboBox, LaderTypeEntity.LaderPivotGroupID_int, TypeCode.Int32);
     TurnCancelCheckBox.Checked = (Boolean)Hepsa.Core.Common.PersentationController.GetEntityValue(LaderTypeEntity.TurnCancel_bit, TypeCode.Boolean);
 }
예제 #3
0
 private void LaderTypeID_intComboBox_SelectionChangeCommitted(object sender, EventArgs e)
 {
     try
     {
         HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory LaderTypeFactory = new HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory();
         HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys    LaderTypeKey     = new HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys();
         LaderTypeKey.LaderTypeID_int = (Int32?)LaderTypeID_intComboBox.SelectedValue;
         HPS.BLL.LaderTypeBLL.BLLLaderType_T LaderTypeEntity = LaderTypeFactory.GetBy(LaderTypeKey);
         if (LaderTypeEntity.LaderTypeID_int != 0)
         {
             LaderTypeCode_nvcTextBox.Text = LaderTypeEntity.LaderTypeCode_nvc;
         }
     }
     catch (Exception ex)
     {
         Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
     }
 }
예제 #4
0
        protected override void ShowForm()
        {
            this.FillCombo();
            HPS.BLL.CarBLL.BLLCar_TFactory CarFactory = new HPS.BLL.CarBLL.BLLCar_TFactory();
            HPS.BLL.CarBLL.BLLCar_T        CarEntity  = CarFactory.GetBy((HPS.BLL.CarBLL.BLLCar_TKeys)Key);
            if (CarEntity == null)
            {
                throw new HPS.Exceptions.CarNotFound();
            }
            CarCardDate_nvcTextBox.Text   = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.CarCardDate_nvc, TypeCode.String));
            CarCardNumber_nvcTextBox.Text = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.CarCardNumber_nvc, TypeCode.String));
            PlateType_nvcTextBox.Text     = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.PlateType_nvc, TypeCode.String));
            NumberPlate_nvcTextBox.Text   = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.NumberPlate_nvc, TypeCode.String));
            SerialPlate_nvcTextBox.Text   = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.SerialPlate_nvc, TypeCode.String));
            Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref PlateCityID_intComboBox, CarEntity.PlateCityID_int, TypeCode.Int32);
            Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref PlateColorID_intComboBox, CarEntity.PlateColorID_int, TypeCode.Int32);
            Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref CountryID_intComboBox, CarEntity.CountryID_int, TypeCode.Int32);
            CountryCode_nvcTextBox.Text           = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.CountryCode_nvc, TypeCode.String));
            YearType_nvcTextBox.Text              = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.YearType_nvc, TypeCode.String));
            ProductionYear_intNumericTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.ProductionYear_int, TypeCode.Int32).ToString();
            Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref LaderTypeID_intComboBox, CarEntity.LaderTypeID_int, TypeCode.Int32);
            Active_bit.Checked = Convert.ToBoolean(Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.Active_bit, TypeCode.Boolean));

            if (LaderTypeID_intComboBox.SelectedValue != null)
            {
                HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory LaderTypeFactory = new HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory();
                HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys    LaderTypeKey     = new HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys();
                LaderTypeKey.LaderTypeID_int = (Int32?)LaderTypeID_intComboBox.SelectedValue;
                HPS.BLL.LaderTypeBLL.BLLLaderType_T LaderTypeEntity = LaderTypeFactory.GetBy(LaderTypeKey);
                if (LaderTypeEntity.LaderTypeID_int != 0)
                {
                    LaderTypeCode_nvcTextBox.Text = LaderTypeEntity.LaderTypeCode_nvc;
                }
            }
            SystemCode_nvcTextBox.Text      = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.SystemCode_nvc, TypeCode.String));
            System_nvcTextBox.Text          = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.System_nvc, TypeCode.String));
            Capacity_fltNumericTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.Capacity_flt, TypeCode.Double).ToString();
            Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref InfractionGroupID_intComboBox, CarEntity.InfractionGroupID_int, TypeCode.Int32);
            InsertDate_nvcTextBox.Text  = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.InsertDate_nvc, TypeCode.String));
            UpdateDate_nvcTextBox.Text  = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.UpdateDate_nvc, TypeCode.String));
            Active_bitCheckBox.Checked  = (Boolean)Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.Active_bit, TypeCode.Boolean);
            Deleted_bitCheckBox.Checked = (Boolean)Hepsa.Core.Common.PersentationController.GetEntityValue(CarEntity.Deleted_bit, TypeCode.Boolean);
        }
예제 #5
0
        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";
        }