Esempio n. 1
0
        private void CallUpdateUserFilter(RequestType ARequestType, int AFilterId, string ADescr,
           string AFilterExpr)
        {
            try
            {
                UserFiltersOpsmgrDal userFiltersDal = new UserFiltersOpsmgrDal(sqlConnectionStr);
                UserFiltersOpsmgrDto filterData = new UserFiltersOpsmgrDto();
                filterData.Id = AFilterId;
                filterData.UserId = p_UserId;
                filterData.Descr = ADescr;
                filterData.FilterExpr = AFilterExpr;

                switch (ARequestType)
                {
                    case RequestType.Insert:
                        {
                            Int32 newId = userFiltersDal.Insert(filterData);
                            if (newId > 0)
                            {
                                DataRow row = userFiltersView.NewRow();
                                row["Id"] = newId;
                                row["Descr"] = filterData.Descr;
                                row["FilterExpr"] = filterData.FilterExpr;
                                userFiltersView.Rows.Add(row);
                                luedUserFilter.EditValue = newId;
                            }
                            break;
                        }
                    case RequestType.Update:
                        {
                            Int32 rowsUpdated = userFiltersDal.Update(filterData);
                            if (rowsUpdated > 0)
                            {
                                DataRow row = userFiltersView.Rows.Find(filterData.Id);
                                row["Descr"] = filterData.Descr;
                                row["FilterExpr"] = filterData.FilterExpr;
                                userFiltersView.AcceptChanges();
                            }
                            break;
                        }
                    case RequestType.Delete:
                        {
                            Int32 rowsDeleted = userFiltersDal.Delete(filterData.Id);
                            if (rowsDeleted > 0)
                            {
                                DataRow row = userFiltersView.Rows.Find(filterData.Id);
                                row.Delete();
                                userFiltersView.AcceptChanges();
                            }
                            break;
                        }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("An error occurred while updating the User Filter data used internally by " + APP_NAME + "." + Environment.NewLine +
                    "Error CNF-059 in " + FORM_NAME + ".CallUpdateUserFilter(): " + ex.Message);
            }
        }
Esempio n. 2
0
 private void CallGetUserFilters()
 {
     try
     {
         UserFiltersOpsmgrDal userFiltersDal = new UserFiltersOpsmgrDal(sqlConnectionStr);
         IList<UserFiltersOpsmgrDto> userFilterList;
         //if (isTestMode)
         //    userFilterList = userFiltersDal.GetAllStub();
         //else
         userFilterList = userFiltersDal.GetAll(p_UserId);
         if (userFilterList != null)
             for (int i = 0; i < userFilterList.Count; i++)
             {
                 DataRow row = userFiltersView.NewRow();
                 row["Id"] = userFilterList[i].Id;
                 row["Descr"] = userFilterList[i].Descr;
                 row["FilterExpr"] = userFilterList[i].FilterExpr;
                 userFiltersView.Rows.Add(row);
             }
     }
     catch (Exception ex)
     {
         throw new Exception("An error occurred while populating the User Filter data used internally by " + APP_NAME + "." + Environment.NewLine +
              "Error CNF-058 in " + FORM_NAME + ".CallGetUserFilters(): " + ex.Message);
     }
 }