Beispiel #1
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            HPS.BLL.InfractionBLL.BLLInfraction_TFactory InfractionFactory = new HPS.BLL.InfractionBLL.BLLInfraction_TFactory();

            try
            {
                if (Hepsa.Core.Common.MessageBox.ConfirmDeleteMessage() == false)
                {
                    return;
                }


                HPS.BLL.InfractionBLL.BLLInfraction_TFactory Infraction_TFactory = new HPS.BLL.InfractionBLL.BLLInfraction_TFactory();
                HPS.BLL.InfractionBLL.BLLInfraction_TKeys    InfractionKey       = new HPS.BLL.InfractionBLL.BLLInfraction_TKeys();

                InfractionKey.InfractionID_int = (Int32)InfractionGridView.CurrentRow.Cells["colInfractionID_int"].Value;
                InfractionFactory.Delete(InfractionKey);

                DataRow[] dr = ((DataTable)this.InfractionGridView.DataSource).Select(HPS.BLL.InfractionBLL.BLLInfraction_T.Infraction_TField.InfractionID_int.ToString() + "='" + InfractionKey.InfractionID_int.ToString() + "'");
                if (dr.Length > 0)
                {
                    dr[0].Delete();
                }
                ((DataTable)this.InfractionGridView.DataSource).AcceptChanges();
            }

            catch (Exception ex)
            {
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
            }
        }
Beispiel #2
0
        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 DriverFirstName_nvc     = Convert.ToString(value[0]);
                string DriverLastName_nvc      = Convert.ToString(value[1]);
                Int64? DriverNationalCode_bint = (Int64?)value[2];
                string NumberPlate_nvc         = Convert.ToString(value[3]);
                string SerialPlate_nvc         = Convert.ToString(value[4]);
                string PlateCityCode_nvc       = Convert.ToString(value[5]);
                Int32? CompanyID_int           = (Int32?)value[6];

                string InfractionCondition = string.Empty;

                if (!string.IsNullOrEmpty(DriverFirstName_nvc) && !string.IsNullOrEmpty(DriverLastName_nvc) && !string.IsNullOrEmpty(DriverNationalCode_bint.ToString()))
                {
                    InfractionCondition = string.Format(" ([Infraction_T].[SolverUserName_nvc] IS NULL) AND ([Infraction_T].[SolveDate_nvc] IS NULL) AND ([Infraction_T].[SolveTime_nvc] IS NULL) AND Infraction_T.DriverFirstName_nvc='{0}' AND Infraction_T.DriverLastName_nvc='{1}' AND Infraction_T.DriverNationalCode_bint='{2}'", DriverFirstName_nvc, DriverLastName_nvc, DriverNationalCode_bint);
                }
                else if (!string.IsNullOrEmpty(NumberPlate_nvc) && !string.IsNullOrEmpty(SerialPlate_nvc) && !string.IsNullOrEmpty(PlateCityCode_nvc))
                {
                    InfractionCondition = string.Format(" ([Infraction_T].[SolverUserName_nvc] IS NULL) AND ([Infraction_T].[SolveDate_nvc] IS NULL) AND ([Infraction_T].[SolveTime_nvc] IS NULL) AND Infraction_T.NumberPlate_nvc='{0}' AND Infraction_T.SerialPlate_nvc='{1}' AND Infraction_T.PlateCityCode_nvc='{2}'", NumberPlate_nvc, SerialPlate_nvc, PlateCityCode_nvc);
                }
                else
                {
                    InfractionCondition = string.Format(" ([Infraction_T].[SolverUserName_nvc] IS NULL) AND ([Infraction_T].[SolveDate_nvc] IS NULL) AND ([Infraction_T].[SolveTime_nvc] IS NULL) AND Infraction_T.CompanyID_int={0}", CompanyID_int);
                }

                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>();

                InfractionList = InfractionFactory.GetAllByCondition(InfractionCondition);
                if (InfractionList != null && InfractionList.Count > 0)
                {
                    this.Description = Exceptions.ExceptionCs.DuplicateInfraction;
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (System.Exception ex)
            {
                this.Description = ex.Message;
                return(false);
            }
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
 private void CompanyID_intComboBox_SelectionChangeCommitted(object sender, EventArgs e)
 {
     if (CompanyID_intComboBox.SelectedValue != null)
     {
         HPS.BLL.InfractionBLL.BLLInfraction_TFactory InfractionFactory = new HPS.BLL.InfractionBLL.BLLInfraction_TFactory();
         DataTable InfractionDataTable = new DataTable();
         InfractionFactory.GetAllByCondition(string.Format("[Infraction_T].CompanyID_int ={0} ", CompanyID_intComboBox.SelectedValue), ref InfractionDataTable);
         this.InfractionGridView.DataSource = InfractionDataTable;
         lastName_nvctextBox.Text           = string.Empty;
         SerialPlate_nvctextBox.Text        = string.Empty;
         NumberPlate_nvctextBox.Text        = string.Empty;
     }
 }
Beispiel #5
0
 private void LoadInfraction()
 {
     try
     {
         HPS.BLL.InfractionBLL.BLLInfraction_TFactory InfractionFactory = new HPS.BLL.InfractionBLL.BLLInfraction_TFactory();
         DataTable InfractionDataTable = new DataTable();
         InfractionFactory.GetAll(ref InfractionDataTable);
         this.InfractionGridView.DataSource = InfractionDataTable;
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Beispiel #6
0
 private void SerialPlate_nvctextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         if (string.IsNullOrEmpty(SerialPlate_nvctextBox.Text) == false || string.IsNullOrEmpty(NumberPlate_nvctextBox.Text) == false)
         {
             HPS.BLL.InfractionBLL.BLLInfraction_TFactory InfractionFactory = new HPS.BLL.InfractionBLL.BLLInfraction_TFactory();
             DataTable InfractionDataTable = new DataTable();
             InfractionFactory.GetAllByCondition(string.Format("[Infraction_T].SerialPlate_nvc Like N'%{0}%' And [Infraction_T].NumberPlate_nvc Like N'%{1}%'", SerialPlate_nvctextBox.Text, NumberPlate_nvctextBox.Text), ref InfractionDataTable);
             this.InfractionGridView.DataSource = InfractionDataTable;
             lastName_nvctextBox.Text           = string.Empty;
         }
     }
 }
Beispiel #7
0
 private void EditButton_Click(object sender, EventArgs e)
 {
     try
     {
         HPS.BLL.InfractionBLL.BLLInfraction_TKeys InfractionKey = new HPS.BLL.InfractionBLL.BLLInfraction_TKeys();
         InfractionKey.InfractionID_int = (Int32)this.InfractionGridView.CurrentRow.Cells["colInfractionID_int"].Value;
         HPS.BLL.InfractionBLL.BLLInfraction_TFactory InfractionFactory = new HPS.BLL.InfractionBLL.BLLInfraction_TFactory();
         HPS.BLL.InfractionBLL.BLLInfraction_T        InfractionEntity  = InfractionFactory.GetBy(InfractionKey);
         if (!string.IsNullOrEmpty(InfractionEntity.RegisterUserName_nvc) && !string.IsNullOrEmpty(InfractionEntity.RegisterDate_nvc))
         {
             registered = true;
         }
         InfractionEntityForm Infraction = new InfractionEntityForm(BaseEntityForm1.enmState.Edit, (DataTable)this.InfractionGridView.DataSource, InfractionKey, registered);
         Infraction.ShowDialog();
     }
     catch (Exception ex)
     {
         Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
     }
 }
Beispiel #8
0
        private void TurnallowdedButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.TrafficGridView.CurrentRow == null)
                {
                    throw new ApplicationException(HPS.Exceptions.ExceptionCs.TrafficNotSelected);
                }

                string title_nvc = TrafficGridView.CurrentRow.Cells[colLaderType_nvc.Name].Value.ToString();
                if (title_nvc.Contains("بونكر") || title_nvc.Contains("تانكر") || title_nvc.Contains("كمپرسي"))
                {
                    throw new ApplicationException("امکان نوبت دهی برای " + title_nvc + " وجود ندارد");
                }

                if ((bool)TrafficGridView.CurrentRow.Cells[colWithLade_bit.Name].Value == true)
                {
                    throw new ApplicationException("امکان نوبت دهی برای کامیون های با بار وجود ندارد");
                }
                Int64?TrafficID = (Int64?)Hepsa.Core.Common.PersentationController.GetEntityValue(this.TrafficGridView.CurrentRow.Cells["colTrafficID_bint"].Value, TypeCode.Int64);

                if (!TrafficID.HasValue)
                {
                    throw new HPS.Exceptions.TrafficNotFound();
                }

                Int32? CarID         = null;
                Int64? DriverID      = null;
                string FirstName     = string.Empty;
                string LastName      = string.Empty;
                Int64? NationaCode   = null;
                string NumberPlate   = string.Empty;
                string SerialPlate   = string.Empty;
                string PlateCityCode = string.Empty;

                if (TrafficGridView.CurrentRow != null)
                {
                    if (TrafficGridView.CurrentRow.Cells[colCarID_int.Name].Value != null)
                    {
                        CarID = (Int32?)Hepsa.Core.Common.PersentationController.GetEntityValue(TrafficGridView.CurrentRow.Cells[colCarID_int.Name].Value, TypeCode.Int32);
                    }
                    if (TrafficGridView.CurrentRow.Cells[colDriverID_bint.Name].Value != null)
                    {
                        DriverID = (Int64?)Hepsa.Core.Common.PersentationController.GetEntityValue(TrafficGridView.CurrentRow.Cells[colDriverID_bint.Name].Value, TypeCode.Int64);
                    }
                    FirstName   = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(TrafficGridView.CurrentRow.Cells[colFirstName_nvc.Name].Value, TypeCode.String));
                    LastName    = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(TrafficGridView.CurrentRow.Cells[colLastName_nvc.Name].Value, TypeCode.String));
                    NationaCode = (Int64?)Hepsa.Core.Common.PersentationController.GetEntityValue(TrafficGridView.CurrentRow.Cells[colNationalCode_int.Name].Value, TypeCode.Int64);
                    NumberPlate = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(TrafficGridView.CurrentRow.Cells[colNumberPlate_nvc.Name].Value, TypeCode.String));
                    SerialPlate = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(TrafficGridView.CurrentRow.Cells[colSerialPlate_nvc.Name].Value, TypeCode.String));


                    HPS.BLL.InfractionBLL.BLLInfraction_TFactory InfractionFactory = new HPS.BLL.InfractionBLL.BLLInfraction_TFactory();
                    string InfractionCondition = string.Format("[Infraction_T].NumberPlate_nvc='{0}'  AND Infraction_T.SerialPlate_nvc='{1}' AND ([Infraction_T].[SolverUserName_nvc] IS NULL) AND ([Infraction_T].[SolveDate_nvc] IS NULL) AND ([Infraction_T].[SolveTime_nvc] IS NULL)", NumberPlate, SerialPlate);
                    List <HPS.BLL.InfractionBLL.BLLInfraction_T> InfractionList = InfractionFactory.GetAllByCondition(InfractionCondition);
                    if (InfractionList != null && InfractionList.Count > 0 && InfractionList[0].TurnAccept_bit)
                    {
                        throw new ApplicationException("ناوگان متخلف است" + "(" + InfractionList[0].CommentControl_nvc + ")");
                    }
                    HPS.Present.TurnManagement.TurnAcceptionForm frm = new TurnAcceptionForm(TrafficID.Value, (DataTable)this.TrafficGridView.DataSource);
                    frm.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
            }
        }