public void Update(HPS.BLL.LaderTypeBLL.BLLLaderType_T businessObject, HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys businessObjectKey) { try { if (businessObject.LaderTypeID_int == businessObjectKey.LaderTypeID_int) { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueLaderTypeID_int") == false) { throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString()); } } else { if (businessObject.IsValid() == false) { throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString()); } } _dataObject.Update(businessObject, businessObjectKey); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
private void DeleteButton_Click(object sender, EventArgs e) { HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory LaderTypeFactory = new HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory(); try { if (Hepsa.Core.Common.MessageBox.ConfirmDeleteMessage() == false) { return; } HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory LaderType_TFactory = 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"].Value; LaderTypeFactory.Delete(LaderTypeKey); DataRow[] dr = ((DataTable)this.LaderTypeGridView.DataSource).Select(HPS.BLL.LaderTypeBLL.BLLLaderType_T.LaderType_TField.LaderTypeID_int.ToString() + "='" + LaderTypeKey.LaderTypeID_int.ToString() + "'"); if (dr.Length > 0) { dr[0].Delete(); } ((DataTable)this.LaderTypeGridView.DataSource).AcceptChanges(); } catch (Exception ex) { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); } }
private void EditButton_Click(object sender, EventArgs e) { HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys LaderTypeKey = new HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys(); LaderTypeKey.LaderTypeID_int = (Int32)this.LaderTypeGridView.CurrentRow.Cells["colLaderTypeID_int"].Value; LaderTypeEntityForm LaderType = new LaderTypeEntityForm(BaseEntityForm1.enmState.Edit, (DataTable)this.LaderTypeGridView.DataSource, LaderTypeKey); LaderType.ShowDialog(); }
public HPS.BLL.LaderTypeBLL.BLLLaderType_T SelectByPrimaryKey(HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_LaderType_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter LaderTypeID_int = new SqlParameter(); LaderTypeID_int.ParameterName = "@LaderTypeID_int"; LaderTypeID_int.SqlDbType = SqlDbType.Int; LaderTypeID_int.Direction = ParameterDirection.Input; LaderTypeID_int.IsNullable = false; LaderTypeID_int.Value = businessObjectKey.LaderTypeID_int; this.Command.Parameters.Add(LaderTypeID_int); if (ControlConnection) { this.BeginTransaction(); } IDataReader dataReader = this.Command.ExecuteReader(); HPS.BLL.LaderTypeBLL.BLLLaderType_T businessObject = new HPS.BLL.LaderTypeBLL.BLLLaderType_T(); if (dataReader.Read()) { PopulateBusinessObjectFromReader(businessObject, dataReader); } else { businessObject = null; } if (dataReader.IsClosed == false) { dataReader.Close(); } if (ControlConnection) { this.Commit(); } return(businessObject); } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }
protected override void Edit() { HPS.BLL.SaloonBLL.BLLSaloon_TFactory SaloonFactory = new HPS.BLL.SaloonBLL.BLLSaloon_TFactory(); try { HPS.BLL.SaloonBLL.BLLSaloon_T SaloonEntity = new HPS.BLL.SaloonBLL.BLLSaloon_T(); SaloonEntity.SaloonID_int = ((HPS.BLL.SaloonBLL.BLLSaloon_TKeys)Key).SaloonID_int; SaloonEntity.Saloon_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(Saloon_nvcTextBox.Text, TypeCode.String).ToString(); SaloonEntity.TurnDistinictAfterCredit_int = (Int32?)Hepsa.Core.Common.PersentationController.GetEntityValue(TurnDistinictAfterCredit_intNumericTextBox.NumericText, TypeCode.Int32); SaloonEntity.TurnNumberInLadeAnnouncement_int = (Int32?)Hepsa.Core.Common.PersentationController.GetEntityValue(TurnNumberInLadeAnnouncement_intNumericTextBox.NumericText, TypeCode.Int32); if (Hepsa.Core.Common.MessageBox.ConfirmMessage(HPS.Exceptions.ExceptionCs.EditMessage) == true) { SaloonFactory.BeginProc(); SaloonFactory.Update(SaloonEntity, (HPS.BLL.SaloonBLL.BLLSaloon_TKeys)Key); HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory LaderTypeFactory = new HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory(); HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys LaderTypeKey = new HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys(); foreach (HPS.BLL.LaderTypeBLL.BLLLaderType_T item in LaderTypeFactory.GetAllBy(BLL.LaderTypeBLL.BLLLaderType_T.LaderType_TField.SaloonID_int, SaloonEntity.SaloonID_int)) { item.SaloonID_int = null; LaderTypeKey.LaderTypeID_int = item.LaderTypeID_int; LaderTypeFactory.Update(item, LaderTypeKey); } foreach (HPS.BLL.LaderTypeBLL.BLLLaderType_T item in lstLaderTypeCheckBox.CheckedItems) { item.SaloonID_int = SaloonEntity.SaloonID_int; LaderTypeKey.LaderTypeID_int = item.LaderTypeID_int; LaderTypeFactory.Update(item, LaderTypeKey); } //for (int i = 0; i < lstLaderTypeCheckBox.CheckedItems.Count; i++) //{ // ((HPS.BLL.LaderTypeBLL.BLLLaderType_T)this.lstLaderTypeCheckBox.CheckedItems[i]).SaloonID_int = SaloonEntity.SaloonID_int; // LaderTypeKey.LaderTypeID_int = ((HPS.BLL.LaderTypeBLL.BLLLaderType_T)this.lstLaderTypeCheckBox.CheckedItems[i]).LaderTypeID_int; // LaderTypeFactory.Update(((HPS.BLL.LaderTypeBLL.BLLLaderType_T)this.lstLaderTypeCheckBox.CheckedItems[i]), LaderTypeKey); //} SaloonFactory.CommitProc(); if (DataTable != null) { DataRow[] dr = DataTable.Select(HPS.BLL.SaloonBLL.BLLSaloon_T.Saloon_TField.SaloonID_int.ToString() + " = " + ((HPS.BLL.SaloonBLL.BLLSaloon_TKeys)Key).SaloonID_int.ToString() + ""); if (dr.Length > 0) { dr[0][HPS.BLL.SaloonBLL.BLLSaloon_T.Saloon_TField.SaloonID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(SaloonEntity.SaloonID_int, TypeCode.Int32); dr[0][HPS.BLL.SaloonBLL.BLLSaloon_T.Saloon_TField.Saloon_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(SaloonEntity.Saloon_nvc, TypeCode.String); dr[0][HPS.BLL.SaloonBLL.BLLSaloon_T.Saloon_TField.TurnDistinictAfterCredit_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(SaloonEntity.TurnDistinictAfterCredit_int, TypeCode.Int32); dr[0][HPS.BLL.SaloonBLL.BLLSaloon_T.Saloon_TField.TurnNumberInLadeAnnouncement_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(SaloonEntity.TurnNumberInLadeAnnouncement_int, TypeCode.Int32); } DataTable.AcceptChanges(); } } } catch (Exception ex) { SaloonFactory.RollBackProc(); throw ex; } }
public void GetBy(HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys keys, ref System.Data.DataTable dataTable) { try { _dataObject.SelectByPrimaryKey(keys, ref dataTable); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
public HPS.BLL.LaderTypeBLL.BLLLaderType_T GetBy(HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys keys) { try { return(_dataObject.SelectByPrimaryKey(keys)); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
public void Delete(HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys keys) { try { _dataObject.Delete(keys); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
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(); }
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); } }
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); }
public void SelectByPrimaryKey(HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys businessObjectKey, ref System.Data.DataTable dataTable) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); SqlDataAdapter sqlDataAdapter = new System.Data.SqlClient.SqlDataAdapter(this.Command); this.Command.CommandText = "[sp_LaderType_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter LaderTypeID_int = new SqlParameter(); LaderTypeID_int.ParameterName = "@LaderTypeID_int"; LaderTypeID_int.SqlDbType = SqlDbType.Int; LaderTypeID_int.Direction = ParameterDirection.Input; LaderTypeID_int.IsNullable = false; LaderTypeID_int.Value = businessObjectKey.LaderTypeID_int; this.Command.Parameters.Add(LaderTypeID_int); if (ControlConnection) { this.BeginTransaction(); } sqlDataAdapter.Fill(dataTable); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }
protected override void Insert() { HPS.BLL.SaloonBLL.BLLSaloon_TFactory SaloonFactory = new HPS.BLL.SaloonBLL.BLLSaloon_TFactory(); try { HPS.BLL.SaloonBLL.BLLSaloon_T SaloonEntity = new HPS.BLL.SaloonBLL.BLLSaloon_T(); SaloonEntity.Saloon_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(Saloon_nvcTextBox.Text, TypeCode.String).ToString(); SaloonEntity.TurnDistinictAfterCredit_int = (Int32?)Hepsa.Core.Common.PersentationController.GetEntityValue(TurnDistinictAfterCredit_intNumericTextBox.NumericText, TypeCode.Int32); SaloonEntity.TurnNumberInLadeAnnouncement_int = (Int32?)Hepsa.Core.Common.PersentationController.GetEntityValue(TurnNumberInLadeAnnouncement_intNumericTextBox.NumericText, TypeCode.Int32); SaloonFactory.BeginProc(); SaloonFactory.Insert(SaloonEntity); HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory LaderTypeFactory = new HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory(); HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys LaderTypeKey = new HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys(); for (int i = 0; i < lstLaderTypeCheckBox.CheckedItems.Count; i++) { ((HPS.BLL.LaderTypeBLL.BLLLaderType_T) this.lstLaderTypeCheckBox.CheckedItems[i]).SaloonID_int = SaloonEntity.SaloonID_int; LaderTypeKey.LaderTypeID_int = ((HPS.BLL.LaderTypeBLL.BLLLaderType_T) this.lstLaderTypeCheckBox.CheckedItems[i]).LaderTypeID_int; LaderTypeFactory.Update(((HPS.BLL.LaderTypeBLL.BLLLaderType_T) this.lstLaderTypeCheckBox.CheckedItems[i]), LaderTypeKey); } SaloonFactory.CommitProc(); if (DataTable != null) { DataRow dr = this.DataTable.NewRow(); dr[HPS.BLL.SaloonBLL.BLLSaloon_T.Saloon_TField.SaloonID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(SaloonEntity.SaloonID_int, TypeCode.Int32); dr[HPS.BLL.SaloonBLL.BLLSaloon_T.Saloon_TField.Saloon_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(SaloonEntity.Saloon_nvc, TypeCode.String); dr[HPS.BLL.SaloonBLL.BLLSaloon_T.Saloon_TField.TurnDistinictAfterCredit_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(SaloonEntity.TurnDistinictAfterCredit_int, TypeCode.Int32); dr[HPS.BLL.SaloonBLL.BLLSaloon_T.Saloon_TField.TurnNumberInLadeAnnouncement_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(SaloonEntity.TurnNumberInLadeAnnouncement_int, TypeCode.Int32); DataTable.Rows.Add(dr); DataTable.AcceptChanges(); } this.ClearForm(this); } catch (Exception ex) { SaloonFactory.RollBackProc(); throw ex; } }
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"; }
public void Update(HPS.BLL.LaderTypeBLL.BLLLaderType_T businessObject, HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_LaderType_T_Update]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter LaderTypeCode_nvc = new SqlParameter(); LaderTypeCode_nvc.ParameterName = "@LaderTypeCode_nvc"; LaderTypeCode_nvc.SqlDbType = SqlDbType.NVarChar; LaderTypeCode_nvc.Direction = ParameterDirection.Input; LaderTypeCode_nvc.IsNullable = false; LaderTypeCode_nvc.Value = businessObject.LaderTypeCode_nvc; this.Command.Parameters.Add(LaderTypeCode_nvc); SqlParameter LaderType_nvc = new SqlParameter(); LaderType_nvc.ParameterName = "@LaderType_nvc"; LaderType_nvc.SqlDbType = SqlDbType.NVarChar; LaderType_nvc.Direction = ParameterDirection.Input; LaderType_nvc.IsNullable = false; LaderType_nvc.Value = businessObject.LaderType_nvc; this.Command.Parameters.Add(LaderType_nvc); SqlParameter MinTruckWeight_dec = new SqlParameter(); MinTruckWeight_dec.ParameterName = "@MinTruckWeight_dec"; MinTruckWeight_dec.SqlDbType = SqlDbType.Decimal; MinTruckWeight_dec.Direction = ParameterDirection.Input; MinTruckWeight_dec.IsNullable = false; if (businessObject.MinTruckWeight_dec.HasValue == false) { MinTruckWeight_dec.Value = DBNull.Value; } else { MinTruckWeight_dec.Value = businessObject.MinTruckWeight_dec; } this.Command.Parameters.Add(MinTruckWeight_dec); SqlParameter MaxTruckWeight_dec = new SqlParameter(); MaxTruckWeight_dec.ParameterName = "@MaxTruckWeight_dec"; MaxTruckWeight_dec.SqlDbType = SqlDbType.Decimal; MaxTruckWeight_dec.Direction = ParameterDirection.Input; MaxTruckWeight_dec.IsNullable = true; if (businessObject.MaxTruckWeight_dec.HasValue == false) { MaxTruckWeight_dec.Value = DBNull.Value; } else { MaxTruckWeight_dec.Value = businessObject.MaxTruckWeight_dec; } this.Command.Parameters.Add(MaxTruckWeight_dec); SqlParameter Active_bit = new SqlParameter(); Active_bit.ParameterName = "@Active_bit"; Active_bit.SqlDbType = SqlDbType.Bit; Active_bit.Direction = ParameterDirection.Input; Active_bit.IsNullable = true; Active_bit.Value = businessObject.Active_bit; this.Command.Parameters.Add(Active_bit); SqlParameter SaloonID_int = new SqlParameter(); SaloonID_int.ParameterName = "@SaloonID_int"; SaloonID_int.SqlDbType = SqlDbType.Int; SaloonID_int.Direction = ParameterDirection.Input; SaloonID_int.IsNullable = false; if (businessObject.SaloonID_int.HasValue == false) { SaloonID_int.Value = DBNull.Value; } else { SaloonID_int.Value = businessObject.SaloonID_int; } this.Command.Parameters.Add(SaloonID_int); SqlParameter LaderPivotGroupID_int = new SqlParameter(); LaderPivotGroupID_int.ParameterName = "@LaderPivotGroupID_int"; LaderPivotGroupID_int.SqlDbType = SqlDbType.Int; LaderPivotGroupID_int.Direction = ParameterDirection.Input; LaderPivotGroupID_int.IsNullable = true; if (businessObject.LaderPivotGroupID_int.HasValue == false) { LaderPivotGroupID_int.Value = DBNull.Value; } else { LaderPivotGroupID_int.Value = businessObject.LaderPivotGroupID_int; } this.Command.Parameters.Add(LaderPivotGroupID_int); SqlParameter pk_LaderTypeID_int = new SqlParameter(); pk_LaderTypeID_int.ParameterName = "@pk_LaderTypeID_int"; pk_LaderTypeID_int.SqlDbType = SqlDbType.Int; pk_LaderTypeID_int.Direction = ParameterDirection.Input; pk_LaderTypeID_int.IsNullable = false; pk_LaderTypeID_int.Value = businessObjectKey.LaderTypeID_int; this.Command.Parameters.Add(pk_LaderTypeID_int); SqlParameter TurnCancel_bit = new SqlParameter(); TurnCancel_bit.ParameterName = "@TurnCancel_bit"; TurnCancel_bit.SqlDbType = SqlDbType.Bit; TurnCancel_bit.Direction = ParameterDirection.Input; TurnCancel_bit.IsNullable = false; TurnCancel_bit.Value = businessObject.TurnCancel_bit; this.Command.Parameters.Add(TurnCancel_bit); if (ControlConnection) { this.BeginTransaction(); } this.Command.ExecuteNonQuery(); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }
public ChooseSaloonForm(Hepsa.Core.PL.BaseEntityParentForm.enmState State, DataTable DataTable, HPS.BLL.LaderTypeBLL.BLLLaderType_TKeys Key) : base(State, DataTable, Key) { InitializeComponent(); }