Exemple #1
0
        /// <summary>
        /// This method is used to update code details
        /// </summary>
        /// <param name="objCodeProp"></param>
        /// <returns></returns>
        /// <createdOn>May-24-2016</createdon>
        public bool UpdateCodeAdminDetails(CodeProp objCodeProp)
        {
            bool result = false;

            try
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                using (PortStorageEntities psEntities = new PortStorageEntities())
                {
                    Code code = psEntities.Codes.Where(c => c.CodeID == objCodeProp.CodeID).FirstOrDefault();
                    code.Code1             = objCodeProp.Code1;
                    code.CodeType          = objCodeProp.CodeType;
                    code.RecordStatus      = objCodeProp.RecordStatus;
                    code.CodeDescription   = objCodeProp.CodeDescription;
                    code.Value1            = objCodeProp.Value1;
                    code.Value1Description = objCodeProp.Value1Description;
                    code.Value2            = objCodeProp.Value2;
                    code.Value2Description = objCodeProp.Value2Description;
                    code.SortOrder         = objCodeProp.SortOrder;
                    code.UpdatedDate       = objCodeProp.UpdatedDate;
                    code.UpdatedBy         = objCodeProp.UpdatedBy;
                    psEntities.SaveChanges();
                    result = true;
                    return(result);
                }
            }
            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));
            }
        }
 public static void SetCodeAdminValueMethodCmdReferesh(CodeProp value)
 {
     if (OnSetCodeAdminValueEvtCmdReferesh != null)
     {
         OnSetCodeAdminValueEvtCmdReferesh(value);
     }
 }
 public static void SetCodeAdminValueMethod(CodeProp value)
 {
     if (OnSetCodeAdminValueEvt != null)
     {
         OnSetCodeAdminValueEvt(value);
     }
 }
Exemple #4
0
        /// <summary>
        /// This method is used to get all code admin details for update and delete functionality and fill form
        /// </summary>
        /// <param name="codePropInfo"></param>
        public void GetCodeAdminValue(CodeProp codePropInfo)
        {
            if (codePropInfo != null)
            {
                EnabledCancel     = false;
                EnabledDelete     = true;
                EnabledFind       = true;
                EnabledModify     = true;
                EnabledNew        = true;
                EnabledSaveUpdate = false;
                Text = Resources.btnUpdate;

                IsReadOnlyButton     = false;
                IsReadOnlyButtonSave = false;
                IsReadOnly           = false;
                CodeID            = codePropInfo.CodeID;
                RecordStatus      = codePropInfo.RecordStatus;
                CodeType          = codePropInfo.CodeType;
                CodeName          = codePropInfo.CodeName;
                Code1             = codePropInfo.Code1;
                CodeDescription   = codePropInfo.CodeDescription;
                Value1            = codePropInfo.Value1;
                Value1Description = codePropInfo.Value1Description;
                Value2            = codePropInfo.Value2;
                Value2Description = codePropInfo.Value2Description;
                SortOrder         = codePropInfo.SortOrder;
                CreationDate      = codePropInfo.CreationDate;
                CreatedBy         = codePropInfo.CreatedBy;
                UpdatedBy         = codePropInfo.UpdatedBy;
                UpdatedDate       = codePropInfo.UpdatedDate;
            }
        }
Exemple #5
0
        /// <summary>
        /// Function to Search the Billing Period List.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>void</returns>
        /// <createdBy></createdBy>
        /// <createdOn>May 20,2016</createdOn>
        public void FindCode(object obj)
        {
            CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

            try
            {
                Count = 0;
                if (obj == null)
                {
                    CurrentPageIndex = 0;
                }
                if (CurrentPageIndex == 0)
                {
                    Application.Current.Properties["FindUserGridLastScrollOffset"] = 0;
                    Application.Current.Properties["FindUserGridCurrentPageIndex"] = 0;
                }

                CodeProp objCodeProp = new CodeProp();
                objCodeProp.CurrentPageIndex = CurrentPageIndex;
                objCodeProp.PageSize         = CurrentPageIndex > 0 ? _GridPageSizeOnScroll : _GridPageSize;;
                objCodeProp.DefaultPageSize  = _GridPageSize;
                objCodeProp.CodeType         = CodeType;
                var list = new ObservableCollection <CodeProp>(_serviceInstance.FindCode(objCodeProp));
                if (CurrentPageIndex == 0)
                {
                    CodeList = null;
                    CodeList = new ObservableCollection <CodeProp>(list);
                }
                else
                {
                    if (CodeList != null && CodeList.Count > 0)
                    {
                        foreach (CodeProp ud in new ObservableCollection <CodeProp>(list))
                        {
                            CodeList.Add(ud);
                        }
                    }
                }
                Count = CodeList.ToList().Where(x => x.TotalPageCount > 0).FirstOrDefault().TotalPageCount;
            }
            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));
            }
        }
Exemple #6
0
        /// <summary>
        /// This function is used to Delete Code Admin Record
        /// </summary>
        /// <param name="obj"></param>
        public void DeleteCodeAdminRecord(object obj)
        {
            bool result = false;

            CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            try
            {
                MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show(Resources.MsgDeleteConfirm, Resources.msgTitleMessageBoxDelete, System.Windows.MessageBoxButton.YesNo);
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    CodeProp objCodeProp = new CodeProp();

                    objCodeProp.CodeID = CodeID;

                    result = _serviceInstance.DeleteCodeAdminDetails(objCodeProp.CodeID);

                    if (result)
                    {
                        MessageBox.Show(Resources.msgDeleteSuccessfully, Resources.msgTitleMessageBox);
                        ResetCodeAdminWindow();
                        IsReadOnly           = false;
                        IsReadOnlyButton     = false;
                        IsReadOnlyButtonSave = false;
                        EnabledCancel        = false;
                        EnabledDelete        = false;
                        EnabledFind          = true;
                        EnabledModify        = false;
                        EnabledNew           = true;
                        EnabledSaveUpdate    = false;
                        Text = Resources.btnSave;;
                        AcceptChanges();
                    }
                }
            }
            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));
            }
        }
Exemple #7
0
 /// <summary>
 /// This method is used to update code details
 /// </summary>
 /// <param name="objCodeProp"></param>
 /// <returns></returns>
 /// <createdOn>May-24-2016</createdon>
 public bool UpdateCodeAdminDetails(CodeProp objCodeProp)
 {
     try
     {
         CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
         CodeDAL objCodeDAL = new CodeDAL();
         return(objCodeDAL.UpdateCodeAdminDetails(objCodeProp));
     }
     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 #8
0
        /// <summary>
        /// To Add the Record of Code
        /// </summary>
        /// <param name="objCodeProp"></param>
        /// <returns>Int</returns>
        /// <createdBy></createdBy>
        /// <createdOn>May-21,2016</createdOn>
        public int AddCodeAdmin(CodeProp objCodeProp)
        {
            using (PortStorageEntities psEntities = new PortStorageEntities())
            {
                int codeID;
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                try
                {
                    Code objCode = new Code();
                    objCode.CodeType          = objCodeProp.CodeType;
                    objCode.Code1             = objCodeProp.Code1;
                    objCode.CodeDescription   = objCodeProp.CodeDescription;
                    objCode.Value1            = objCodeProp.Value1;
                    objCode.Value1Description = objCodeProp.Value1Description;
                    objCode.Value2            = objCodeProp.Value2;
                    objCode.Value2Description = objCodeProp.Value2Description;
                    objCode.RecordStatus      = objCodeProp.RecordStatus;
                    objCode.SortOrder         = objCodeProp.SortOrder;
                    objCode.CreationDate      = objCodeProp.CreationDate;
                    objCode.CreatedBy         = objCodeProp.CreatedBy;
                    objCode.UpdatedDate       = objCodeProp.UpdatedDate;
                    objCode.UpdatedBy         = objCodeProp.UpdatedBy;
                    objCode.CodeName          = objCodeProp.CodeName;
                    objCode.Description       = objCodeProp.Description;
                    objCode.DataType          = objCodeProp.DataType;
                    objCode.DataSubType       = objCodeProp.DataSubType;
                    objCode.DAIOnlyInd        = objCodeProp.DAIOnlyInd;


                    psEntities.Codes.Add(objCode);   /// Insert the Record in BillingPeriod Table.
                    psEntities.SaveChanges();        /// Check the Chenges in Table After Record Insertion.
                    codeID = objCode.CodeID;         /// Return the BillingPeriodID of Inserted Billing Period.
                }
                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(codeID);
            }
        }
Exemple #9
0
        /// <summary>
        /// To Find Billing Period Record
        /// </summary>
        /// <param name="objBillingPeriod"></param>
        /// <returns>IList<BillingPeriod></returns>
        /// <createdBy></createdBy>
        /// <createdOn>May-20,2016</createdOn>
        public IList <CodeProp> FindCode(CodeProp objCodeProp)
        {
            IList <CodeProp> listCodeProp;
            CodeDAL          objCodeDAL = new CodeDAL(); /// Creating The Object of BillingDAL

            CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            try
            {
                listCodeProp = objCodeDAL.FindCode(objCodeProp); /// sending the new record model to the data access layer.
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                objCodeDAL = null;
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
            return(listCodeProp);
        }
Exemple #10
0
        /// <summary>
        /// To Find Code Record
        /// </summary>
        /// <param name="objCodeProp"></param>
        /// <returns>IList<BillingPeriod></returns>
        /// <createdBy></createdBy>
        /// <createdOn>May-23,2016</createdOn>
        public IList <CodeProp> FindCode(CodeProp objCodeProp)
        {
            using (PortStorageEntities psEntities = new PortStorageEntities())
            {
                IList <CodeProp> listCodeProp;
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                try
                {
                    if (string.Equals(objCodeProp.CodeType, "All"))
                    {
                        listCodeProp = psEntities.Codes.Select(y => new CodeProp()
                        {
                            CodeID            = y.CodeID,
                            Code1             = y.Code1,
                            CodeDescription   = y.CodeDescription,
                            CodeName          = y.CodeName,
                            CodeType          = y.CodeType,
                            CreatedBy         = y.CreatedBy,
                            CreationDate      = y.CreationDate,
                            DAIOnlyInd        = y.DAIOnlyInd,
                            DataSubType       = y.DataSubType,
                            DataType          = y.DataType,
                            Description       = y.Description,
                            RecordStatus      = y.RecordStatus,
                            SortOrder         = y.SortOrder,
                            UpdatedBy         = y.UpdatedBy,
                            UpdatedDate       = y.UpdatedDate,
                            Value1            = y.Value1,
                            Value1Description = y.Value1Description,
                            Value2            = y.Value2,
                            Value2Description = y.Value2Description
                        }).OrderBy(x => x.CodeType).ThenBy(x => x.SortOrder).ThenBy(x => x.Code1).ToList();
                    }
                    else
                    {
                        listCodeProp = psEntities.Codes.Where(x => string.Equals(x.CodeType, objCodeProp.CodeType)).Select(y => new CodeProp()
                        {
                            CodeID            = y.CodeID,
                            Code1             = y.Code1,
                            CodeDescription   = y.CodeDescription,
                            CodeName          = y.CodeName,
                            CodeType          = y.CodeType,
                            CreatedBy         = y.CreatedBy,
                            CreationDate      = y.CreationDate,
                            DAIOnlyInd        = y.DAIOnlyInd,
                            DataSubType       = y.DataSubType,
                            DataType          = y.DataType,
                            Description       = y.Description,
                            RecordStatus      = y.RecordStatus,
                            SortOrder         = y.SortOrder,
                            UpdatedBy         = y.UpdatedBy,
                            UpdatedDate       = y.UpdatedDate,
                            Value1            = y.Value1,
                            Value1Description = y.Value1Description,
                            Value2            = y.Value2,
                            Value2Description = y.Value2Description
                        }).OrderBy(x => x.CodeType).ThenBy(x => x.SortOrder).ThenBy(x => x.Code1).ToList();
                    }
                    //var pageCount = listCodeProp.ToList().Count;
                    //var queryResult = listCodeProp.ToList().Skip(objCodeProp.CurrentPageIndex * objCodeProp.PageSize).Take(objCodeProp.PageSize).ToList();
                    //if (queryResult != null && queryResult.Count > 0)
                    //{
                    //    queryResult.FirstOrDefault().TotalPageCount = pageCount;
                    //}
                    //return queryResult.OrderBy(x=>x.SortOrder).ThenBy(x=>x.CodeType).ThenBy(x=>x.Code1).ToList();

                    var pageCount = listCodeProp.ToList().Count;
                    if (objCodeProp.CurrentPageIndex == 0)
                    {
                        var queryResult = listCodeProp.ToList().Skip(objCodeProp.CurrentPageIndex * objCodeProp.PageSize).Take(objCodeProp.PageSize).ToList();
                        //var queryResult = query.ToList().Skip(objFindUserProp.CurrentPageIndex * objFindUserProp.PageSize).Take(objFindUserProp.PageSize).ToList();
                        if (queryResult != null && queryResult.Count > 0)
                        {
                            queryResult.FirstOrDefault().TotalPageCount = pageCount;
                        }
                        return(queryResult.OrderBy(x => x.CodeType).ThenBy(x => x.SortOrder).ThenBy(x => x.Code1).ToList());
                    }
                    else
                    {
                        var queryResult = listCodeProp.ToList().Skip((objCodeProp.CurrentPageIndex * objCodeProp.PageSize) + (objCodeProp.DefaultPageSize - objCodeProp.PageSize)).Take(objCodeProp.PageSize).ToList();
                        //var queryResult = query.ToList().Skip(objFindUserProp.CurrentPageIndex * objFindUserProp.PageSize).Take(objFindUserProp.PageSize).ToList();
                        if (queryResult != null && queryResult.Count > 0)
                        {
                            queryResult.FirstOrDefault().TotalPageCount = pageCount;
                        }
                        return(queryResult.OrderBy(x => x.CodeType).ThenBy(x => x.SortOrder).ThenBy(x => x.Code1).ToList());
                    }
                }
                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 #11
0
        /// <summary>
        /// This function is used to insert code admin details in database
        /// </summary>
        /// <param name="obj"></param>
        public void InsertCode(object obj)
        {
            try
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

                CodeProp objCodeProp = new CodeProp();
                objCodeProp.CodeID            = CodeID;
                objCodeProp.RecordStatus      = RecordStatus;
                objCodeProp.CodeType          = CodeType;
                objCodeProp.Code1             = Code1;
                objCodeProp.Value1            = Value1;
                objCodeProp.Value2            = Value2;
                objCodeProp.CodeDescription   = CodeDescription;
                objCodeProp.Value1Description = Value1Description;
                objCodeProp.Value2Description = Value2Description;
                objCodeProp.SortOrder         = SortOrder;
                objCodeProp.CreationDate      = CreationDate;
                objCodeProp.CreatedBy         = CreatedBy;

                if (CodeID > 0)
                {
                    objCodeProp.UpdatedBy   = Application.Current.Properties["LoggedInUserName"].ToString();
                    objCodeProp.UpdatedDate = DateTime.Now;
                    if (!string.IsNullOrEmpty(CodeType))
                    {
                        if (!string.IsNullOrEmpty(Code1))
                        {
                            bool result = _serviceInstance.ModifyCodeAdminRecord(objCodeProp);

                            if (result)
                            {
                                DelegateEventCodeAdmin.SetCodeAdminValueMethodCmdReferesh(objCodeProp);
                                MessageBox.Show(Resources.msgUpdatedSuccessfully);
                                //ResetCodeAdminWindow();
                                IsReadOnly           = false;
                                IsReadOnlyButton     = false;
                                isReadOnlyButtonSave = false;
                                EnabledCancel        = false;
                                EnabledFind          = true;
                                if (CodeID > 0)
                                {
                                    EnabledDelete = true;
                                    EnabledModify = true;
                                }
                                else
                                {
                                    EnabledDelete = false;
                                    EnabledModify = false;
                                }
                                EnabledNew        = true;
                                EnabledSaveUpdate = false;

                                Text = Resources.btnSave;

                                AcceptChanges();
                            }
                            else
                            {
                                MessageBox.Show(Resources.ErrorToUpdate);
                            }
                        }
                        else
                        {
                            MessageBox.Show(Resources.ErrorEnterCode);
                        }
                    }
                    else
                    {
                        MessageBox.Show(Resources.MsgSelectCodeType);
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(CodeType))
                    {
                        if (!string.IsNullOrEmpty(Code1))
                        {
                            bool isValidRecord = false;

                            isValidRecord = _serviceInstance.CheckDuplicateCodeAndType(Code1, CodeType);

                            if (isValidRecord)
                            {
                                int data = _serviceInstance.AddCodeAdmin(objCodeProp);

                                if (data > 0)
                                {
                                    MessageBox.Show(Resources.msgInsertedSuccessfully);
                                    CodeID               = data;
                                    IsReadOnly           = false;
                                    IsReadOnlyButton     = false;
                                    isReadOnlyButtonSave = false;
                                    EnabledCancel        = false;
                                    EnabledFind          = true;
                                    if (CodeID > 0)
                                    {
                                        EnabledDelete = true;
                                        EnabledModify = true;
                                    }
                                    else
                                    {
                                        EnabledDelete = false;
                                        EnabledModify = false;
                                    }
                                    EnabledNew        = true;
                                    EnabledSaveUpdate = false;
                                    Text = Resources.btnSave;
                                    AcceptChanges();
                                }

                                else
                                {
                                    MessageBox.Show(Resources.ErrorInserted);
                                }
                            }
                            else
                            {
                                MessageBox.Show(Resources.ErrorDuplicateCode);
                            }
                        }
                        else
                        {
                            MessageBox.Show(Resources.ErrorEnterCode);
                        }
                    }
                    else
                    {
                        MessageBox.Show(Resources.MsgSelectCodeType);
                    }
                }
            }
            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));
            }
        }