Ejemplo n.º 1
0
        protected void DriverInformationSave()
        {
            HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_TFactory DriverSpecificationFactory = new HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_TFactory();
            try
            {
                HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_T DriverSpecificationEntity = new HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_T();
                DriverSpecificationEntity.DriverCardNumber_nvc          = Hepsa.Core.Common.PersentationController.GetEntityValue(_DriverCardNumber, TypeCode.String).ToString();
                DriverSpecificationEntity.FirstName_nvc                 = Hepsa.Core.Common.PersentationController.GetEntityValue(FirstName_nvcTextBox.Text, TypeCode.String).ToString();
                DriverSpecificationEntity.LastName_nvc                  = Hepsa.Core.Common.PersentationController.GetEntityValue(LastName_nvcTextBox.Text, TypeCode.String).ToString();
                DriverSpecificationEntity.NationalCode_int              = (Int64)Hepsa.Core.Common.PersentationController.GetEntityValue(NationalCode_intNumericTextBox.NumericText, TypeCode.Int64);
                DriverSpecificationEntity.licenceNumber_nvc             = Hepsa.Core.Common.PersentationController.GetEntityValue(licenceNumber_nvcTextBox.Text, TypeCode.String).ToString();
                DriverSpecificationEntity.CarExamination_bit            = false;
                DriverSpecificationEntity.LicenceEnd_nvc                = Hepsa.Core.Common.PersentationController.GetEntityValue(LicenceEnd_nvcTextBox.Text, TypeCode.String).ToString();
                DriverSpecificationEntity.Insurance_bit                 = false;
                DriverSpecificationEntity.InsuranceStartDate_nvc        = string.Empty;
                DriverSpecificationEntity.ClassID_int                   = (Int32?)Hepsa.Core.Common.PersentationController.GetEntityValue(ClassID_intComboBox.SelectedValue, TypeCode.Int32);
                DriverSpecificationEntity.HealthCard_bit                = false;
                DriverSpecificationEntity.HealthCardStartDate_nvc       = string.Empty;
                DriverSpecificationEntity.HealthCardEndDate_nvc         = Hepsa.Core.Common.PersentationController.GetEntityValue(HealthCardEndDate_nvcTextBox.Text, TypeCode.String).ToString();
                DriverSpecificationEntity.DriverCardSharje_bit          = false;
                DriverSpecificationEntity.DriverCardSharjeStartDate_nvc = string.Empty;
                DriverSpecificationEntity.DriverCardSharjeEndDate_nvc   = Hepsa.Core.Common.PersentationController.GetEntityValue(DriverCardSharjeEndDate_nvcTextBox.Text, TypeCode.String).ToString();
                DriverSpecificationEntity.StatisticCard_bit             = false;

                HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_TKeys driverSpecificationkey = new BLL.DriverSpecificationBLL.BLLDriverSpecification_TKeys();
                if (_DriverSpecificationID != 0)
                {
                    driverSpecificationkey.DriverSpecificationID_int = _DriverSpecificationID;
                    DriverSpecificationFactory.BeginProc();
                    DriverSpecificationFactory.Update(DriverSpecificationEntity, driverSpecificationkey);
                    DriverSpecificationFactory.CommitProc();
                    Hepsa.Core.Common.MessageBox.InformationMessage("اطلاعات ثبت شد");
                }
                else
                {
                    DriverSpecificationFactory.BeginProc();
                    DriverSpecificationFactory.Insert(DriverSpecificationEntity);
                    DriverSpecificationFactory.CommitProc();
                    Hepsa.Core.Common.MessageBox.InformationMessage("اطلاعات ثبت شد");
                }
            }
            catch (Exception ex)
            {
                DriverSpecificationFactory.RollBackProc();
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void CarControlButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(_CarCardNumber))
                {
                    //HPS.Present.DriverSpecification.DriverSpecificationEntityForm frm = new HPS.Present.DriverSpecification.DriverSpecificationEntityForm(CarCardNumber_nvcTextBox.Text,false);
                    //frm.ShowDialog();

                    List <string> DateEroorList = new List <string>();


                    Hepsa.Core.Validation.TodayDateRule InsuranceEndDate_nvcRule = new Hepsa.Core.Validation.TodayDateRule("InsuranceEndDate_nvc", "تاريخ اتمام بيمه");
                    if (InsuranceEndDate_nvcRule.Validate(Hepsa.Core.Common.PersentationController.GetMaskedTextBoxValue(InsuranceEndDate_nvcTextBox)) == false)
                    {
                        DateEroorList.Add(InsuranceEndDate_nvcRule.Description + "\n");
                    }

                    Hepsa.Core.Validation.TodayDateRule CarExaminationEndTodayDateRule = new Hepsa.Core.Validation.TodayDateRule("CarExaminationEndDate_nvc", "تاريخ اتمام معاينه");
                    if (CarExaminationEndTodayDateRule.Validate(Hepsa.Core.Common.PersentationController.GetMaskedTextBoxValue(CarExaminationEndDate_nvcTextBox)) == false)
                    {
                        DateEroorList.Add(CarExaminationEndTodayDateRule.Description + "\n");
                    }

                    ////////////add not null rule

                    Hepsa.Core.Validation.NotNullRule InsuranceEndDateNotNullRule = new Hepsa.Core.Validation.NotNullRule("InsuranceEndDate_nvc", "تاريخ اتمام بيمه");
                    if (InsuranceEndDateNotNullRule.Validate(Hepsa.Core.Common.PersentationController.GetMaskedTextBoxValue(InsuranceEndDate_nvcTextBox)) == false)
                    {
                        DateEroorList.Add(InsuranceEndDateNotNullRule.Description + "\n");
                    }

                    Hepsa.Core.Validation.NotNullRule CarExaminationEndDateNotNullRule = new Hepsa.Core.Validation.NotNullRule("CarExaminationEndDate_nvc", "تاريخ اتمام معاينه");
                    if (CarExaminationEndDateNotNullRule.Validate(Hepsa.Core.Common.PersentationController.GetMaskedTextBoxValue(CarExaminationEndDate_nvcTextBox)) == false)
                    {
                        DateEroorList.Add(CarExaminationEndDateNotNullRule.Description + "\n");
                    }

                    ////////////add date rule
                    Hepsa.Core.Validation.DateRule <string> InsuranceEndDateaDateRule = new Hepsa.Core.Validation.DateRule <string>("InsuranceEndDate_nvc", "تاريخ اتمام بيمه", null, null);
                    if (InsuranceEndDateaDateRule.Validate(Hepsa.Core.Common.PersentationController.GetMaskedTextBoxValue(InsuranceEndDate_nvcTextBox)) == false)
                    {
                        DateEroorList.Add(InsuranceEndDateaDateRule.Description + "\n");
                    }

                    Hepsa.Core.Validation.DateRule <string> CarExaminationEndDateRule = new Hepsa.Core.Validation.DateRule <string>("CarExaminationEndDate_nvc", "تاريخ اتمام معاينه", null, null);
                    if (CarExaminationEndDateRule.Validate(Hepsa.Core.Common.PersentationController.GetMaskedTextBoxValue(CarExaminationEndDate_nvcTextBox)) == false)
                    {
                        DateEroorList.Add(CarExaminationEndDateRule.Description + "\n");
                    }

                    if (DateEroorList != null && DateEroorList.Count > 0)
                    {
                        throw new ApplicationException(DateEroorList.Aggregate((i, j) => i + j));
                    }

                    HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_TFactory DriverSpecificationFactory = new HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_TFactory();
                    try
                    {
                        HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_T DriverSpecificationEntity = new HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_T();
                        DriverSpecificationEntity.CarExamination_bit        = false;
                        DriverSpecificationEntity.Insurance_bit             = false;
                        DriverSpecificationEntity.HealthCard_bit            = false;
                        DriverSpecificationEntity.DriverCardSharje_bit      = false;
                        DriverSpecificationEntity.StatisticCard_bit         = false;
                        DriverSpecificationEntity.CarCardNumber_nvc         = _CarCardNumber;
                        DriverSpecificationEntity.CarExaminationEndDate_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(CarExaminationEndDate_nvcTextBox.Text, TypeCode.String).ToString();
                        DriverSpecificationEntity.InsuranceEndDate_nvc      = Hepsa.Core.Common.PersentationController.GetEntityValue(InsuranceEndDate_nvcTextBox.Text, TypeCode.String).ToString();

                        HPS.BLL.DriverSpecificationBLL.BLLDriverSpecification_TKeys driverSpecificationkey = new BLL.DriverSpecificationBLL.BLLDriverSpecification_TKeys();
                        if (_DriverSpecificationID != 0)
                        {
                            driverSpecificationkey.DriverSpecificationID_int = _DriverSpecificationID;
                            DriverSpecificationFactory.BeginProc();
                            DriverSpecificationFactory.Update(DriverSpecificationEntity, driverSpecificationkey);
                            DriverSpecificationFactory.CommitProc();
                            Hepsa.Core.Common.MessageBox.InformationMessage("اطلاعات ثبت شد");
                        }
                        else
                        {
                            DriverSpecificationFactory.BeginProc();
                            DriverSpecificationFactory.Insert(DriverSpecificationEntity);
                            DriverSpecificationFactory.CommitProc();
                            Hepsa.Core.Common.MessageBox.InformationMessage("اطلاعات ثبت شد");
                        }
                    }
                    catch (Exception ex)
                    {
                        DriverSpecificationFactory.RollBackProc();
                        Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
                    }


                    //DriverInformationSave();
                }
                else
                {
                    throw new ApplicationException("اطلاعات ناوگان خالی است");
                }
            }
            catch (Exception ex)
            {
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
            }
        }