Exemple #1
0
        /// <summary>
        /// function to Add the Damage Code
        /// </summary>
        /// <param name="portStorageVehiclesId"></param>
        /// <returns>Int<returns>
        /// <createdBy></createdBy>
        /// <createdOn>May-10,2016</createdOn>
        public int AddDamageCode(DamageCodeProp objDamageCodeProp)
        {
            int value = 0;

            try
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                // creating the object of PortStorageEntities Database
                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    //Sta: SELECT TOP 1 PSVehicleInspectionID
                    //Sta: FROM PSVehicleInspection
                    //Sta: WHERE PortStorageVehiclesID = @[iVehicleID]
                    //Sta: AND InspectionType = @[iInspectionType]
                    //Sta: ORDER BY PSVehicleInspectionID DESC
                    var getInspectioDetails = (from qry in objAppWorksEntities.PSVehicleInspections where qry.PortStorageVehiclesID == objDamageCodeProp.PortStorageVehiclesID && qry.InspectionType == objDamageCodeProp.PSVehicleInspectionID orderby qry.PSVehicleInspectionID descending select qry).FirstOrDefault();
                    if (getInspectioDetails == null)
                    {
                        System.Data.Entity.Core.Objects.ObjectParameter objReturnId   = new System.Data.Entity.Core.Objects.ObjectParameter("rRecordID", typeof(int));
                        System.Data.Entity.Core.Objects.ObjectParameter objReturnCode = new System.Data.Entity.Core.Objects.ObjectParameter("rReturnCode", 0);
                        var getResult = objAppWorksEntities.spCreatePortStorageVehicleInspectionRecord(objDamageCodeProp.PortStorageVehiclesID, objDamageCodeProp.PSVehicleInspectionID, objDamageCodeProp.InspectionDate, objDamageCodeProp.InspectedBy, 0, 0, 0, "", objReturnId, objReturnCode);
                    }

                    if (getInspectioDetails == null)
                    {
                        getInspectioDetails = (from qry in objAppWorksEntities.PSVehicleInspections where qry.PortStorageVehiclesID == objDamageCodeProp.PortStorageVehiclesID && qry.InspectionType == objDamageCodeProp.PSVehicleInspectionID orderby qry.PSVehicleInspectionID descending select qry).FirstOrDefault();
                    }
                    // add damagecode
                    System.Data.Entity.Core.Objects.ObjectParameter rReturnCode = new System.Data.Entity.Core.Objects.ObjectParameter("rReturnCode", typeof(int));
                    var result = objAppWorksEntities.spProcessPortStorageDamageCode(objDamageCodeProp.PortStorageVehiclesID, getInspectioDetails.PSVehicleInspectionID, objDamageCodeProp.DamageCode, objDamageCodeProp.DamageDescription, objDamageCodeProp.InspectionDate, objDamageCodeProp.InspectedBy, rReturnCode);

                    //objAppWorksEntities.Database.ExecuteSqlCommand("spProcessPortStorageDamageCode", objDamageCodeProp.PortStorageVehiclesID, getInspectioDetails.PSVehicleInspectionID, objDamageCodeProp.DamageCode, objDamageCodeProp.DamageDescription, objDamageCodeProp.InspectionDate, objDamageCodeProp.InspectedBy, rReturnCode);

                    if (rReturnCode != null && rReturnCode.Value != null)
                    {
                        value = Convert.ToInt32(rReturnCode);
                    }
                }
            }
            catch (Exception)
            {
                //throw;
            }
            finally
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
            return(value);
        }
        /// <summary>
        /// function to Add the Damage Code
        /// </summary>
        /// <param name="portStorageVehiclesId"></param>
        /// <returns>Int<returns>
        /// <createdBy></createdBy>
        /// <createdOn>May-10,2016</createdOn>
        public int AddDamageCode(DamageCodeProp objDamageCodeProp)
        {
            PortStorageDamageDetailsDAL objPortStorageDamageDetailsDAL = new PortStorageDamageDetailsDAL();

            CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            try
            {
                //add the details of damage code details.
                return(objPortStorageDamageDetailsDAL.AddDamageCode(objDamageCodeProp));
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }
Exemple #3
0
        /// <summary>
        /// Method To Save The Data.
        /// </summary>
        public async void Save(object obj)
        {
            try
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                if (Vin.Length < 1)
                {
                    MessageBox.Show(Resources.msgVINReq);
                }
                else if (InspectionDate == null)
                {
                    MessageBox.Show(Resources.msgInspectionDateReq);
                }
                else if (string.IsNullOrEmpty(damageCode1) && string.IsNullOrEmpty(damageCode2) && string.IsNullOrEmpty(damageCode3) && string.IsNullOrEmpty(damageCode4) && string.IsNullOrEmpty(damageCode5) && string.IsNullOrEmpty(damageCode6) && string.IsNullOrEmpty(damageCode7) && string.IsNullOrEmpty(damageCode8) && string.IsNullOrEmpty(damageCode9) && string.IsNullOrEmpty(damageCode10))
                {
                    MessageBox.Show(Resources.msgDamageCodeReq);
                }
                else if (string.IsNullOrEmpty(SelectedInspectionType) || selectedInspectionType == "Please Select")
                {
                    MessageBox.Show(Resources.msgInspectionTypeReq);
                }
                else
                {
                    if (SelectedInspectionType.ToLower(CultureInfo.CurrentCulture).Equals(Resources.InspectionType1.ToLower(CultureInfo.CurrentCulture)))
                    {
                        SelectedInspectionID = 0;
                    }
                    else if (SelectedInspectionType.ToLower(CultureInfo.CurrentCulture).Equals(Resources.InspectionType2.ToLower(CultureInfo.CurrentCulture)))
                    {
                        SelectedInspectionID = 1;
                    }
                    else if (SelectedInspectionType.ToLower(CultureInfo.CurrentCulture).Equals(Resources.InspectionType3.ToLower(CultureInfo.CurrentCulture)))
                    {
                        SelectedInspectionID = 2;
                    }
                    bool isError = false;

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

                    if (!string.IsNullOrEmpty(damageCode1))
                    {
                        if ((damageCode1.Length == 5))
                        {
                            damageCodes.Add(damageCode1);
                        }
                        else
                        {
                            MessageBox.Show(Resources.msgDamageCodeNumberValidation);
                            isError = true;
                        }
                    }
                    if (!string.IsNullOrEmpty(damageCode2))
                    {
                        if ((damageCode2.Length == 5))
                        {
                            damageCodes.Add(damageCode2);
                        }
                        else
                        {
                            MessageBox.Show(Resources.msgDamageCodeNumberValidation);
                            isError = true;
                        }
                    }
                    if (!string.IsNullOrEmpty(damageCode3))
                    {
                        if ((damageCode3.Length == 5))
                        {
                            damageCodes.Add(damageCode3);
                        }
                        else
                        {
                            MessageBox.Show(Resources.msgDamageCodeNumberValidation);
                            isError = true;
                        }
                    }
                    if (!string.IsNullOrEmpty(damageCode4))
                    {
                        if ((damageCode4.Length == 5))
                        {
                            damageCodes.Add(damageCode4);
                        }
                        else
                        {
                            MessageBox.Show(Resources.msgDamageCodeNumberValidation);
                            isError = true;
                        }
                    }
                    if (!string.IsNullOrEmpty(damageCode5))
                    {
                        if ((damageCode5.Length == 5))
                        {
                            damageCodes.Add(damageCode5);
                        }
                        else
                        {
                            MessageBox.Show(Resources.msgDamageCodeNumberValidation);
                            isError = true;
                        }
                    }
                    if (!string.IsNullOrEmpty(damageCode6))
                    {
                        if ((damageCode6.Length == 5))
                        {
                            damageCodes.Add(damageCode6);
                        }
                        else
                        {
                            MessageBox.Show(Resources.msgDamageCodeNumberValidation);
                            isError = true;
                        }
                    }
                    if (!string.IsNullOrEmpty(damageCode7))
                    {
                        if ((damageCode7.Length == 5))
                        {
                            damageCodes.Add(damageCode7);
                        }
                        else
                        {
                            MessageBox.Show(Resources.msgDamageCodeNumberValidation);
                            isError = true;
                        }
                    }
                    if (!string.IsNullOrEmpty(damageCode8))
                    {
                        if ((damageCode8.Length == 5))
                        {
                            damageCodes.Add(damageCode8);
                        }
                        else
                        {
                            MessageBox.Show(Resources.msgDamageCodeNumberValidation);
                            isError = true;
                        }
                    }
                    if (!string.IsNullOrEmpty(damageCode9))
                    {
                        if ((damageCode9.Length == 5))
                        {
                            damageCodes.Add(damageCode9);
                        }
                        else
                        {
                            MessageBox.Show(Resources.msgDamageCodeNumberValidation);
                            isError = true;
                        }
                    }
                    if (!string.IsNullOrEmpty(damageCode10))
                    {
                        if ((damageCode10.Length == 5))
                        {
                            damageCodes.Add(damageCode10);
                        }
                        else
                        {
                            MessageBox.Show(Resources.msgDamageCodeNumberValidation);
                            isError = true;
                        }
                    }

                    //if there is no error then save the damage codes
                    if (!isError)
                    {
                        foreach (var code in damageCodes)
                        {
                            DamageCodeProp objDamageCodeProp = new DamageCodeProp();
                            objDamageCodeProp.PortStorageVehiclesID  = VehicleId;
                            objDamageCodeProp.PSVehicleInspectionID  = SelectedInspectionID;
                            objDamageCodeProp.DamageDescription      = string.Empty;
                            objDamageCodeProp.DamageCode             = code;
                            objDamageCodeProp.InspectedBy            = Application.Current.Properties["LoggedInUserName"].ToString();
                            objDamageCodeProp.InspectionDate         = DateTime.Now;
                            objDamageCodeProp.SelectedInspectionType = SelectedInspectionType;
                            await _serviceInstance.AddDamageCodeAsync(objDamageCodeProp);
                        }

                        Close(null);
                        DelegateEventVehicle.SetValueMethodDamageCode("bindgrid");
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogErrorToDb(ex);
                bool displayErrorOnUI = false;
                CommonSettings.logger.LogError(this.GetType(), ex);
                if (displayErrorOnUI)
                {
                    throw;
                }
            }

            finally
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }