示例#1
0
        protected void gridCategories_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            try
            {
                SessionManager.IsEditFormCreated = false;
                //insert category
                CanonCategory cc = new CanonCategory();
                cc.CategoryName = e.NewValues["CategoryName"].ToString();
                cc.InternalId   = e.NewValues["InternalId"].ToString();
                CanonCategory.InsertCategory(cc);

                e.Cancel = true;
                gridCategories.CancelEdit();
                this.BindData();
            }
            catch (Exception ex)
            {
                Logger.Log(string.Format("exception {0}", ex.ToString()), LogLevel.Error);
            }
        }
示例#2
0
 protected void gridCategories_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
 {
     try
     {
         try
         {
             CanonCategory.DeleteCategoryById(int.Parse(e.Keys[0].ToString()));
         }
         catch (ProductAssignedException pex)
         {
             gridCategories.JSProperties["cpDeleteError"] = pex.ProductGroupName;
         }
         e.Cancel = true;
         gridCategories.CancelEdit();
         this.BindData();
     }
     catch (Exception ex)
     {
         Logger.Log(string.Format("exception {0}", ex.ToString()), LogLevel.Error);
     }
 }
示例#3
0
        protected void gridCategories_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            try
            {
                SessionManager.IsEditFormCreated = false;
                int keyToUpdate = int.Parse(e.Keys[0].ToString());
                //update category
                CanonCategory cc = new CanonCategory();
                cc.CategoryName = e.NewValues["CategoryName"].ToString();
                cc.InternalId   = e.NewValues["InternalId"].ToString();
                CanonCategory.UpdateCategoryById(keyToUpdate, cc);

                e.Cancel = true;
                gridCategories.CancelEdit();
                this.BindData();
            }
            catch (Exception ex)
            {
                Logger.Log(string.Format("exception {0}", ex.ToString()), LogLevel.Error);
            }
        }
示例#4
0
 protected void gridCategories_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(e.NewValues["CategoryName"].ToString().Trim()))
         {
             e.RowError = Utilities.GetResourceString("Validators", "CategoryNameMustBeSet");
             return;
         }
         if (string.IsNullOrEmpty(e.NewValues["InternalId"].ToString().Trim()))
         {
             e.RowError = Utilities.GetResourceString("Validators", "CategoryIdMustBeSet");
             return;
         }
         if (CanonCategory.IsCategoryNameExist(e.NewValues["CategoryName"].ToString().Trim()))
         {
             e.RowError = Utilities.GetResourceString("Validators", "CategoryNameAlreadyExist");
             if (string.IsNullOrEmpty(e.RowError))
             {
                 e.RowError = "Category name is already exist.";
             }
             return;
         }
         if (CanonCategory.IsCategoryCodeExist(e.NewValues["InternalId"].ToString().Trim()))
         {
             e.RowError = Utilities.GetResourceString("Validators", "CategoryCodeAlreadyExist");
             if (string.IsNullOrEmpty(e.RowError))
             {
                 e.RowError = "Category code is already exist.";
             }
             return;
         }
     }
     catch (Exception ex)
     {
         Logger.Log(string.Format("exception {0}", ex.ToString()), LogLevel.Error);
     }
 }
示例#5
0
 /// <summary>
 /// Handler for general callback event (filtering, bulk deleting)
 /// </summary>
 /// <param name="source"></param>
 /// <param name="e"></param>
 protected void clbPanelCategories_Callback(object source, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
 {
     try
     {
         if (string.IsNullOrEmpty(e.Parameter))
         {
             List <object> keyValues = gridCategories.GetSelectedFieldValues("CategoryId");
             foreach (object key in keyValues)
             {
                 CanonCategory.DeleteCategoryById(int.Parse(key.ToString()));
             }
         }
         else if (e.Parameter == "Search")
         {
             if (!string.IsNullOrEmpty(txtSearchParam.Text.Trim()))
             {
                 this.FilterText = txtSearchParam.Text;
             }
             this.IsFilterMode = true;
         }
         else if (e.Parameter == "ShowAll")
         {
             this.IsFilterMode = false;
             this.FilterText   = string.Empty;
         }
         this.BindData();
     }
     catch (ProductAssignedException pex)
     {
         clbPanelCategories.JSProperties["cpDeleteError"] = pex.ProductGroupName;
     }
     catch (Exception ex)
     {
         Logger.Log(string.Format("exception {0}", ex.ToString()), LogLevel.Error);
     }
 }