Exemplo n.º 1
0
 public Response <Footers> DeleteFooters([FromBody] Footers footer)
 {
     try
     {
         return(_footerBusiness.DeleteFooters(footer));
     }
     catch (Exception e)
     {
         _logger.Error($"DeleteFooters Failed: {e.Message}\n {e.StackTrace}");
         return(new Response <Footers>(false, e.Message, null));
     }
 }
Exemplo n.º 2
0
 public List <Footers> DeleteFooters(Footers footer)
 {
     try
     {
         var result = ListByStoredProcedure <Footers>(StoredProc.DeleteFooters,
                                                      new StoredProcedureParameter("FooterID", footer.FooterID, DbType.Int32));
         return(result);
     }
     catch (Exception e)
     {
         _logger.Error($"DeleteFooters Failed: {e.Message}\n {e.StackTrace}");
         return(new List <Footers>());
     }
 }
Exemplo n.º 3
0
 public Response <Footers> UpdateFooters([FromBody] Footers footer)
 {
     try
     {
         var osPrincipal = (UserIdentity)System.Web.HttpContext.Current.User;
         var userData    = JsonConvert.DeserializeObject <UserViewModel>(osPrincipal.UserData);
         footer.LastUpdatedBy = userData.CodeUserName;
         return(_footerBusiness.UpdateFooters(footer));
     }
     catch (Exception e)
     {
         _logger.Error($"UpdateFooters Failed: {e.Message}\n {e.StackTrace}");
         return(new Response <Footers>(false, e.Message, null));
     }
 }
Exemplo n.º 4
0
 public Response <Footers> DeleteFooters(Footers footers)
 {
     try
     {
         var data = _footerRepository.DeleteFooters(footers);
         if (data != null && data.Any())
         {
             return(new Response <Footers>(true, "Success", data[0]));
         }
         return(new Response <Footers>(false, "Fail", null));
     }
     catch (Exception e)
     {
         _logger.Error($"DeleteFooters Failed: {e.Message}\n {e.StackTrace}");
         return(new Response <Footers>(false, e.Message, null));
     }
 }
Exemplo n.º 5
0
 public List <Footers> UpdateFooters(Footers footer)
 {
     try
     {
         var result = ListByStoredProcedure <Footers>(StoredProc.UpdateFooters,
                                                      new StoredProcedureParameter("FooterID", footer.FooterID, DbType.Int32)
                                                      , new StoredProcedureParameter("Name", footer.Name, DbType.String)
                                                      , new StoredProcedureParameter("Content", footer.Content, DbType.String)
                                                      , new StoredProcedureParameter("Status", footer.Status, DbType.Boolean)
                                                      , new StoredProcedureParameter("LastUpdatedBy", footer.LastUpdatedBy, DbType.String)
                                                      , new StoredProcedureParameter("LastUpdatedDate", footer.LastUpdatedDate, DbType.DateTime));
         return(result);
     }
     catch (Exception e)
     {
         _logger.Error($"UpdateFooters Failed: {e.Message}\n {e.StackTrace}");
         return(new List <Footers>());
     }
 }
Exemplo n.º 6
0
        private void InitFlexGrid()
        {
            // setup flexgrid
            _flexGrid.AllowFiltering     = true;
            _flexGrid.AllowFiltering     = true;
            _flexGrid.AllowMerging       = AllowMergingEnum.Nodes;
            _flexGrid.HideGroupedColumns = true;
            _flexGrid.ShowErrors         = true;

            ColumnCollection columns = _flexGrid.Cols;

            // setup flexgrid columns
            columns[0].Width = 22;

            Column idColumn = columns["ID"];

            idColumn.Width        = 50;
            idColumn.AllowEditing = false;

            // setup combo list
            IEnumerable <string> products = (from s in _dataSet.Tables["Products"].Rows.Cast <DataRow>() select s)
                                            .Select(x => x["Name"].ToString());

            columns["Product"].ComboList = string.Join("|", products);

            // build image map for countries
            var flagImageMap = new Dictionary <Country, Image>();

            foreach (Country country in Enum.GetValues(typeof(Country)))
            {
                flagImageMap.Add(country, LoadImage(country.ToString()));
            }

            Column countryColumn = columns["Country"];

            // assign image map to country column
            countryColumn.ImageMap     = flagImageMap;
            countryColumn.ImageAndText = true;

            // build image map for colors
            var colorImageMap = new Dictionary <DrawColor, Image>();

            foreach (DrawColor color in Enum.GetValues(typeof(DrawColor)))
            {
                colorImageMap.Add(color, LoadImage(color.ToString()));
            }

            Column colorColumn = columns["Color"];

            // assign image map to color column
            colorColumn.ImageMap     = colorImageMap;
            colorColumn.ImageAndText = true;

            Column priceColumn = columns["Price"];

            priceColumn.Format    = "C2";
            priceColumn.TextAlign = TextAlignEnum.RightCenter;
            priceColumn.Width     = 80;

            ValidationRuleCollection priceEditorValidation = _flexGrid.Cols["Price"].EditorValidation;

            // add validation rules
            priceEditorValidation.Add(new RequiredRule());
            priceEditorValidation.Add(new RangeRule()
            {
                Minimum      = decimal.Zero,
                Maximum      = decimal.MaxValue,
                ErrorMessage = "Price cannot be negative"
            });

            Column changeColumn = columns["Change"];

            changeColumn.Format    = "C2";
            changeColumn.TextAlign = TextAlignEnum.RightCenter;

            Column historyColumn = columns["History"];

            historyColumn.AllowEditing = false;

            // setup sparkline for history column
            historyColumn.ShowSparkline = true;

            Sparkline historySparkline = historyColumn.Sparkline;

            historySparkline.ShowLow  = true;
            historySparkline.ShowHigh = true;

            Column discountColumn = columns["Discount"];

            discountColumn.Format       = "p0";
            discountColumn.AllowEditing = false;
            discountColumn.Width        = 80;

            Column ratingColumn = columns["Rating"];

            ratingColumn.ImageAndText = false;
            ratingColumn.AllowEditing = false;

            columns["Active"].Width = 60;

            Column dateColumn = columns["Date"];

            dateColumn.Format = "g";

            // creating footers
            var footerDescription = new FooterDescription();

            // price aggregate
            var priceAggregateDefinition = new AggregateDefinition()
            {
                Aggregate    = AggregateEnum.Average,
                Caption      = "Average price: ${0:N2}",
                PropertyName = "Price"
            };

            // discount aggregate
            var discountAggregateDefinition = new AggregateDefinition
            {
                Aggregate    = AggregateEnum.Average,
                Caption      = "Average discount: {0:P}",
                PropertyName = "Discount"
            };

            ObservableCollection <AggregateDefinition> aggregates = footerDescription.Aggregates;

            aggregates.Add(priceAggregateDefinition);
            aggregates.Add(discountAggregateDefinition);

            // add footers
            Footers footers = _flexGrid.Footers;

            footers.Descriptions.Add(footerDescription);
            footers.Fixed = true;

            // set details
            _flexGrid.RowDetailProvider = (g, r) => new CustomRowDetail();

            // add red style
            CellStyle redStyle = _flexGrid.Styles.Add("Red");

            redStyle.ImageAlign = ImageAlignEnum.LeftCenter;
            redStyle.ForeColor  = Color.Red;

            // add green style
            CellStyle greenStyle = _flexGrid.Styles.Add("Green");

            greenStyle.ImageAlign = ImageAlignEnum.LeftCenter;
            greenStyle.ForeColor  = Color.Green;

            // add rating style
            CellStyle ratingStyle = _flexGrid.Styles.Add("Rating");

            ratingStyle.ImageAlign = ImageAlignEnum.RightCenter;
        }