public override bool Validate(params object[] value) { try { this.Description = string.Empty; if (value.Length != Field.Length) { this.Description = Hepsa.Core.My.Resources.ValidationMessage.IncorrectDataType; return(false); } string DriverCardNumber_nvc = Convert.ToString(value[0]); string DriverFirstName_nvc = Convert.ToString(value[1]); string DriverLastName_nvc = Convert.ToString(value[2]); Int64? DriverNationalCode_bint = (Int64?)value[3]; HPS.BLL.InfractionBLL.BLLInfraction_TFactory InfractionFactory = new HPS.BLL.InfractionBLL.BLLInfraction_TFactory(); List <HPS.BLL.InfractionBLL.BLLInfraction_T> InfractionList = new List <HPS.BLL.InfractionBLL.BLLInfraction_T>(); if (!string.IsNullOrEmpty(DriverCardNumber_nvc)) { HPS.BLL.DriverBLL.BLLDriver_TFactory DriverFactory = new HPS.BLL.DriverBLL.BLLDriver_TFactory(); List <HPS.BLL.DriverBLL.BLLDriver_T> DriverList = new List <HPS.BLL.DriverBLL.BLLDriver_T>(); DriverList = DriverFactory.GetAllBy(HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.DriverCardNumber_nvc, DriverCardNumber_nvc); if (DriverList != null && DriverList.Count > 0) { InfractionList = InfractionFactory.GetAllBy(HPS.BLL.InfractionBLL.BLLInfraction_T.Infraction_TField.DriverID_bint, DriverList[0].DriverID_bint); if (InfractionList != null && InfractionList.Count > 0) { this.Description = "جهت ادامه کار به مسئول کامپیوتر مراجعه کنید"; return(false); } } } else { string infractionCondition = "Infraction_T.DriverFirstName_nvc='" + DriverFirstName_nvc + "' AND Infraction_T.DriverLastName_nvc='" + DriverLastName_nvc + "' AND Infraction_T.DriverNationalCode_bint='" + DriverNationalCode_bint + "'"; InfractionList = InfractionFactory.GetAllByCondition(infractionCondition); if (InfractionList != null && InfractionList.Count > 0) { this.Description = "جهت ادامه کار به مسئول کامپیوتر مراجعه کنید"; return(false); } } return(true); } catch (System.Exception ex) { this.Description = ex.Message; return(false); } }
private void LoadWithoutDriverCardNumber() { HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_TFactory DriverSpecificationFactory = new HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_TFactory(); DataTable DriverFieldTable = new DataTable(); DriverSpecificationFactory.SelectByDriverField(_FirstName, _LastName, _NationalCode, ref DriverFieldTable); if (DriverFieldTable != null && DriverFieldTable.Rows.Count > 0) { _DriverSpecificationID = (Int32)DriverFieldTable.Rows[0]["DriverSpecificationID_int"]; Key = new HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_TKeys(); Key.DriverSpecificationID_int = _DriverSpecificationID; DriverCardNumber_nvcTextBox.Text = DriverFieldTable.Rows[0]["DriverCardNumber_nvc"].ToString(); FirstName_nvcTextBox.Text = DriverFieldTable.Rows[0]["FirstName_nvc"].ToString(); LastName_nvcTextBox.Text = DriverFieldTable.Rows[0]["LastName_nvc"].ToString(); NationalCode_intNumericTextBox.Text = DriverFieldTable.Rows[0]["NationalCode_int"].ToString(); licenceNumber_nvcTextBox.Text = DriverFieldTable.Rows[0]["licenceNumber_nvc"].ToString(); LicenceEnd_nvcTextBox.Text = DriverFieldTable.Rows[0]["LicenceEnd_nvc"].ToString(); CarExaminationEndDate_nvcTextBox.Text = DriverFieldTable.Rows[0]["CarExaminationEndDate_nvc"].ToString(); InsuranceEndDate_nvcTextBox.Text = DriverFieldTable.Rows[0]["InsuranceEndDate_nvc"].ToString(); ClassID_intComboBox.SelectedValue = DriverFieldTable.Rows[0]["ClassID_int"]; HealthCardEndDate_nvcTextBox.Text = DriverFieldTable.Rows[0]["HealthCardEndDate_nvc"].ToString(); DriverCardSharjeEndDate_nvcTextBox.Text = DriverFieldTable.Rows[0]["DriverCardSharjeEndDate_nvc"].ToString(); } else { HPS.BLL.TrafficBLL.BLLTraffic_TFactory TrafficFactory = new HPS.BLL.TrafficBLL.BLLTraffic_TFactory(); string Condition = "Traffic_T.FirstName_nvc=N'" + _FirstName + "' AND Traffic_T.LastName_nvc=N'" + _LastName + "' AND Traffic_T.NationalCode_int='" + _NationalCode + "'"; List <HPS.BLL.TrafficBLL.BLLTraffic_T> TrafficList = TrafficFactory.GetAllByCondition(Condition); if (TrafficList != null && TrafficList.Count > 0) { DriverCardNumber_nvcTextBox.Text = TrafficList[TrafficList.Count - 1].DriverCardNumber_nvc; FirstName_nvcTextBox.Text = TrafficList[TrafficList.Count - 1].FirstName_nvc; LastName_nvcTextBox.Text = TrafficList[TrafficList.Count - 1].LastName_nvc; NationalCode_intNumericTextBox.Text = Convert.ToString(TrafficList[TrafficList.Count - 1].NationalCode_int); licenceNumber_nvcTextBox.Text = Convert.ToString(TrafficList[TrafficList.Count - 1].licenceNumber_int); } else { HPS.BLL.DriverBLL.BLLDriver_TFactory DriverFactory = new HPS.BLL.DriverBLL.BLLDriver_TFactory(); List <HPS.BLL.DriverBLL.BLLDriver_T> DriverList = DriverFactory.GetAllBy(HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.DriverCardNumber_nvc, _DriverCardNumber); if (DriverList != null && DriverList.Count > 0) { DriverCardNumber_nvcTextBox.Text = DriverList[0].DriverCardNumber_nvc; FirstName_nvcTextBox.Text = DriverList[0].FirstName_nvc; LastName_nvcTextBox.Text = DriverList[0].LastName_nvc; NationalCode_intNumericTextBox.Text = Convert.ToString(DriverList[0].NationalCode_int); licenceNumber_nvcTextBox.Text = Convert.ToString(DriverList[0].licenceNumber_nvc); } } } }
private void LoadWithDriverCardNumber() { HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_TFactory DriverSpecificationFactory = new HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_TFactory(); List <HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_T> DriverSpecificationList = DriverSpecificationFactory.GetAllBy(HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_T.DriverSpecification_TField.NationalCode_int, _NationalCode); if (DriverSpecificationList != null && DriverSpecificationList.Count > 0) { _DriverSpecificationID = DriverSpecificationList[0].DriverSpecificationID_int; Key = new HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_TKeys(); Key.DriverSpecificationID_int = _DriverSpecificationID; DriverCardNumber_nvcTextBox.Text = DriverSpecificationList[0].DriverCardNumber_nvc; FirstName_nvcTextBox.Text = DriverSpecificationList[0].FirstName_nvc; LastName_nvcTextBox.Text = DriverSpecificationList[0].LastName_nvc; NationalCode_intNumericTextBox.Text = Convert.ToString(DriverSpecificationList[0].NationalCode_int); licenceNumber_nvcTextBox.Text = DriverSpecificationList[0].licenceNumber_nvc; LicenceEnd_nvcTextBox.Text = DriverSpecificationList[0].LicenceEnd_nvc; ClassID_intComboBox.SelectedValue = DriverSpecificationList[0].ClassID_int.HasValue?DriverSpecificationList[0].ClassID_int:0; HealthCardEndDate_nvcTextBox.Text = DriverSpecificationList[0].HealthCardEndDate_nvc; DriverCardSharjeEndDate_nvcTextBox.Text = DriverSpecificationList[0].DriverCardSharjeEndDate_nvc; SaveAndCloseButton.Visible = false; } else { Editbutton.Visible = false; HPS.BLL.TrafficBLL.BLLTraffic_TFactory TrafficFactory = new HPS.BLL.TrafficBLL.BLLTraffic_TFactory(); List <HPS.BLL.TrafficBLL.BLLTraffic_T> TrafficList = TrafficFactory.GetAllBy(HPS.BLL.TrafficBLL.BLLTraffic_T.Traffic_TField.NationalCode_int, _NationalCode); if (TrafficList != null && TrafficList.Count > 0) { DriverCardNumber_nvcTextBox.Text = TrafficList[TrafficList.Count - 1].DriverCardNumber_nvc; FirstName_nvcTextBox.Text = TrafficList[TrafficList.Count - 1].FirstName_nvc; LastName_nvcTextBox.Text = TrafficList[TrafficList.Count - 1].LastName_nvc; NationalCode_intNumericTextBox.Text = Convert.ToString(TrafficList[TrafficList.Count - 1].NationalCode_int); licenceNumber_nvcTextBox.Text = Convert.ToString(TrafficList[TrafficList.Count - 1].licenceNumber_int); } else { HPS.BLL.DriverBLL.BLLDriver_TFactory DriverFactory = new HPS.BLL.DriverBLL.BLLDriver_TFactory(); List <HPS.BLL.DriverBLL.BLLDriver_T> DriverList = DriverFactory.GetAllBy(HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.NationalCode_int, _NationalCode); if (DriverList != null && DriverList.Count > 0) { DriverCardNumber_nvcTextBox.Text = DriverList[0].DriverCardNumber_nvc; FirstName_nvcTextBox.Text = DriverList[0].FirstName_nvc; LastName_nvcTextBox.Text = DriverList[0].LastName_nvc; NationalCode_intNumericTextBox.Text = Convert.ToString(DriverList[0].NationalCode_int); licenceNumber_nvcTextBox.Text = Convert.ToString(DriverList[0].licenceNumber_nvc); } } } }
protected override void Insert() { HPS.BLL.DriverBLL.BLLDriver_TFactory DriverFactory = new HPS.BLL.DriverBLL.BLLDriver_TFactory(); if (online) { var driver = DriverFactory.GetAllBy(BLL.DriverBLL.BLLDriver_T.Driver_TField.DriverCardNumber_nvc, DriverCardNumber_nvcTextBox.Text); if (driver.Count > 0) { Edit(); return; } } try { HPS.BLL.DriverBLL.BLLDriver_T DriverEntity = new HPS.BLL.DriverBLL.BLLDriver_T(); DriverEntity.DriverCardDate_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(DriverCardDate_nvcTextBox.Text, TypeCode.String).ToString(); DriverEntity.DriverCardNumber_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(DriverCardNumber_nvcTextBox.Text, TypeCode.String).ToString(); DriverEntity.DriverType_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(DriverType_nvcTextBox.Text, TypeCode.String).ToString(); DriverEntity.FirstName_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(FirstName_nvcTextBox.Text, TypeCode.String).ToString(); DriverEntity.LastName_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(LastName_nvcTextBox.Text, TypeCode.String).ToString(); DriverEntity.InsuranceNumber_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(InsuranceNumber_nvcTextBox.Text, TypeCode.String).ToString(); DriverEntity.CityID_int = (Nullable <Int32>)Hepsa.Core.Common.PersentationController.GetEntityValue(CityID_intComboBox.SelectedValue, TypeCode.Int32); DriverEntity.CityCode_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(CityCode_nvcTextBox.Text, TypeCode.String).ToString(); DriverEntity.licenceNumber_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(licenceNumber_nvcTextBox.Text, TypeCode.String).ToString(); DriverEntity.LicenceCityID_int = (Nullable <Int32>)Hepsa.Core.Common.PersentationController.GetEntityValue(LicenceCityID_intComboBox.SelectedValue, TypeCode.Int32); DriverEntity.LicenceType_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(LicenceType_nvcTextBox.Text, TypeCode.String).ToString(); DriverEntity.LiceniceDate_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(LiceniceDate_nvcTextBox.Text, TypeCode.String).ToString(); DriverEntity.ActivityScope_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(ActivityScope_nvcTextBox.Text, TypeCode.String).ToString(); DriverEntity.NationalCode_int = (Nullable <Int64>)Hepsa.Core.Common.PersentationController.GetEntityValue(NationalCode_intNumericTextBox.NumericText, TypeCode.Int64); DriverEntity.Active_bit = Active_bitCheckBox.Checked; DriverEntity.InfractionGroupID_int = (Nullable <Int32>)Hepsa.Core.Common.PersentationController.GetEntityValue(InfractionGroupID_intComboBox.SelectedValue, TypeCode.Int32); DriverEntity.DocNumber_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(DocNumber_nvcTextBox.Text, TypeCode.String).ToString(); DriverEntity.InsertDate_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(InsertDate_nvcTextBox.Text, TypeCode.String).ToString(); DriverEntity.UpdateDate_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(UpdateDate_nvcTextBox.Text, TypeCode.String).ToString(); DriverEntity.Deleted_bit = Deleted_bitCheckBox.Checked; DriverEntity.Mobile_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(Mobile_nvctextBox.Text, TypeCode.String).ToString(); DriverEntity.Active_bit = Active_bit.Checked; DriverFactory.BeginProc(); DriverFactory.Insert(DriverEntity); DriverFactory.CommitProc(); if (DataTable != null) { DataRow dr = this.DataTable.NewRow(); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.DriverID_bint.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.DriverID_bint, TypeCode.Int64); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.DriverCardDate_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.DriverCardDate_nvc, TypeCode.String); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.DriverCardNumber_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.DriverCardNumber_nvc, TypeCode.String); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.DriverType_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.DriverType_nvc, TypeCode.String); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.FirstName_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.FirstName_nvc, TypeCode.String); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.LastName_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.LastName_nvc, TypeCode.String); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.InsuranceNumber_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.InsuranceNumber_nvc, TypeCode.String); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.CityID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.CityID_int, TypeCode.Int32); dr["CityID_intCity_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(CityID_intComboBox); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.CityCode_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.CityCode_nvc, TypeCode.String); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.licenceNumber_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.licenceNumber_nvc, TypeCode.String); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.LicenceCityID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.LicenceCityID_int, TypeCode.Int32); dr["LicenceCityID_intCity_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(LicenceCityID_intComboBox); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.LicenceType_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.LicenceType_nvc, TypeCode.String); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.LiceniceDate_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.LiceniceDate_nvc, TypeCode.String); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.ActivityScope_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.ActivityScope_nvc, TypeCode.String); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.NationalCode_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.NationalCode_int, TypeCode.Int64); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.Active_bit.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.Active_bit, TypeCode.Boolean); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.InfractionGroupID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.InfractionGroupID_int, TypeCode.Int32); dr["InfractionGroupID_intInfractionGroup_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(InfractionGroupID_intComboBox); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.DocNumber_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.DocNumber_nvc, TypeCode.String); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.InsertDate_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.InsertDate_nvc, TypeCode.String); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.UpdateDate_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.UpdateDate_nvc, TypeCode.String); dr[HPS.BLL.DriverBLL.BLLDriver_T.Driver_TField.Deleted_bit.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(DriverEntity.Deleted_bit, TypeCode.Boolean); DataTable.Rows.Add(dr); DataTable.AcceptChanges(); } this.ClearForm(this); } catch (Exception ex) { DriverFactory.RollBackProc(); throw ex; } }