Advertisement
abhighosh_18

Code Behind

Aug 20th, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.33 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using BusinessLogic;
  8. using System.Data;
  9. using System.Data.SqlClient;
  10. using Facebook;
  11.  
  12. namespace InventoryManagementSys
  13. {
  14.     public partial class CategoryDetails : System.Web.UI.Page
  15.     {
  16.         protected void Page_Load(object sender, EventArgs e)
  17.         {
  18.             if (!IsPostBack)
  19.             {
  20.                 if (Session["user"] != null)
  21.                 {
  22.                     Category catObj = new CategoryLogic().SelectByID(Convert.ToInt32(Request.QueryString["ID"]));
  23.  
  24.                     DataTable dt_prod_count = new ProductLogic().CountProductsInCategory(Convert.ToInt32(Request.QueryString["ID"]));
  25.  
  26.                     txtTotalProdInCat.Text = dt_prod_count.Rows[0]["Count_Products"].ToString();
  27.  
  28.                     lblName.Text = catObj.CategoryName;
  29.                     txtName.Text = catObj.CategoryName;
  30.                     txtDesc.Text = catObj.CategoryDescription;
  31.  
  32.                     imgCatPic.ImageUrl = catObj.CategoryPhoto;
  33.  
  34.                     if (catObj.HeightWidth.Equals("Yes"))
  35.                     {
  36.                         rblYN.SelectedIndex = 0;
  37.                     }
  38.                     else
  39.                     {
  40.                         rblYN.SelectedIndex = 1;
  41.                     }
  42.  
  43.                     txtDateCreated.Text = catObj.DateCreated.ToString();
  44.                     txtDateUpdated.Text = catObj.DateUpdated.ToString();
  45.                 }
  46.             }
  47.             else
  48.             {
  49.                 Response.Redirect("CategoryDetails.aspx?ID=" + Convert.ToInt32(Request.QueryString["ID"]));
  50.             }
  51.  
  52.         }
  53.  
  54.         protected void btnCatPicUpdate_Click(object sender, EventArgs e)
  55.         {
  56.  
  57.         }
  58.  
  59.         protected void btnUpdateDetails_Click(object sender, EventArgs e)
  60.         {
  61.             Category catObj = new Category();
  62.  
  63.             catObj.CategoryName = txtName.Text;
  64.             catObj.CategoryDescription = txtDesc.Text;
  65.             catObj.HeightWidth = rblYN.SelectedValue;
  66.             catObj.CategoryID = Convert.ToInt32(Request.QueryString["ID"]);
  67.  
  68.             int upd_result = new CategoryLogic().Update(catObj);
  69.  
  70.             if (upd_result > 0)
  71.             {
  72.                 catObj.DateUpdated = DateTime.Now;
  73.  
  74.                 int upd_date = new CategoryLogic().UpdateDate(catObj);
  75.  
  76.                 if (upd_date > 0)
  77.                 {
  78.                     ScriptManager.RegisterStartupScript(btnUpdateDetails, btnUpdateDetails.GetType(), "key", string.Format("toastr['success']('{0} - was updated successfully!')", catObj.CategoryName), true);
  79.                 }
  80.                 else
  81.                 {
  82.                     ScriptManager.RegisterStartupScript(btnUpdateDetails, btnUpdateDetails.GetType(), "key", string.Format("toastr['error']('There was some error while updating record for - {0} - Category! Please try again!')", catObj.CategoryName), true);
  83.                 }
  84.             }
  85.             else
  86.             {
  87.                 ScriptManager.RegisterStartupScript(btnUpdateDetails, btnUpdateDetails.GetType(), "key", string.Format("toastr['error']('There was some error while updating record for - {0} - Category! Please try again!')", catObj.CategoryName), true);
  88.             }
  89.         }
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement