private DataTable getSubCatg() { try { IAdmin checkSubCatName = new AdminItems(); DataTable dt = checkSubCatName.checkSubCatName(string.Empty, Int32.Parse(ddl_catagory.SelectedValue)); return(dt); } catch (Exception ex) { lbl_status.Text = HardCodedValues.BuddaResource.CatchBlockError + ex.Message; return(null); } }
private void getFeedBackList() { try { IAdmin getFeedback = new AdminItems(); DataTable feedbackDt = getFeedback.getFeedback(); gv_feedback.DataSource = feedbackDt; gv_feedback.DataBind(); } catch { gv_feedback.DataSource = null; gv_feedback.DataBind(); } }
protected DataTable getItems(int grpCatId) { try { IAdmin getItems = new AdminItems(); DataTable itemDT = getItems.getItems(grpCatId); return(itemDT); } catch (Exception iExp) { grpMsgLbl.Text = "Error Occured" + iExp.Message; return(null); } }
private void getSubCatg() { try { IAdmin checkSubCatName = new AdminItems(); DataTable dt = checkSubCatName.checkSubCatName(txt_SubCatName.Text, Int32.Parse(CatagoryDDL.SelectedValue)); SubCatagoryDDL.DataSource = dt; SubCatagoryDDL.DataTextField = "SubCatName"; SubCatagoryDDL.DataValueField = "SubCatId"; SubCatagoryDDL.DataBind(); } catch (Exception ex) { ItemMessageLbl.Text = HardCodedValues.BuddaResource.CatchBlockError + ex.Message; } }
protected void getcatgs() { try { IAdmin getCats = new AdminItems(); DataTable catgDt = getCats.getCatagories(); ddl_catagory.DataSource = catgDt; ddl_catagory.DataTextField = "CategoryName"; ddl_catagory.DataValueField = "CategoryId"; ddl_catagory.DataBind(); } catch (Exception cExp) { throw cExp; } }
private void getMerchants() { try { IAdmin getmerchants = new AdminItems(); DataTable dt = getmerchants.getMerchants(); MerchantDDL.DataSource = dt; MerchantDDL.DataTextField = "MName"; MerchantDDL.DataValueField = "MId"; MerchantDDL.DataBind(); } catch (Exception ex) { ItemMessageLbl.Text = HardCodedValues.BuddaResource.CatchBlockError + ex.Message; } }
protected void userGrid_RowUpdating(object sender, GridViewUpdateEventArgs e) { int userid = Convert.ToInt32(userGrid.DataKeys[e.RowIndex].Value.ToString()); string username = userGrid.DataKeys[e.RowIndex].Values["UserName"].ToString(); string password = userGrid.DataKeys[e.RowIndex].Values["PWD"].ToString(); TextBox newpassword = (TextBox)userGrid.Rows[e.RowIndex].FindControl("txt_editpwd"); TextBox emailid = (TextBox)userGrid.Rows[e.RowIndex].FindControl("txt_editemailid"); TextBox phno = (TextBox)userGrid.Rows[e.RowIndex].FindControl("txt_editphno"); TextBox address = (TextBox)userGrid.Rows[e.RowIndex].FindControl("txt_editaddress"); CheckBox userstatus = (CheckBox)userGrid.Rows[e.RowIndex].FindControl("cb_editactvsts"); string encryptedpwd; if (password == newpassword.Text) { encryptedpwd = newpassword.Text; } else { encryptedpwd = CLASS.PasswordEncryption.EncryptIt(newpassword.Text); } BusinessEntitiesBS.UserEntities.userobj UpdateUserObj = new BusinessEntitiesBS.UserEntities.userobj(); UpdateUserObj.uname = username; UpdateUserObj.pwd = encryptedpwd; UpdateUserObj.emailid = emailid.Text; UpdateUserObj.phno = phno.Text; UpdateUserObj.address = address.Text; UpdateUserObj.userstatus = userstatus.Checked; IAdmin UpdateUsers = new AdminItems(); int updated = UpdateUsers.UpdateUsers(UpdateUserObj, userid); if (updated != -1) { lbl_status.Text = HardCodedValues.BuddaResource.UpdateSuccess; userGrid.EditIndex = -1; searchDT(txt_username.Text); } else { lbl_status.Text = HardCodedValues.BuddaResource.UpdateFail; } }
protected void getcatgs() { try { IAdmin getCats = new AdminItems(); DataTable catgDt = getCats.getCatagories(); CatagoryDDL.DataSource = catgDt; CatagoryDDL.DataTextField = "CategoryName"; CatagoryDDL.DataValueField = "CategoryId"; CatagoryDDL.DataBind(); grpCatDDL.DataSource = catgDt; grpCatDDL.DataTextField = "CategoryName"; grpCatDDL.DataValueField = "CategoryId"; grpCatDDL.DataBind(); } catch (Exception cExp) { ItemMessageLbl.Text = "Error occured" + cExp.Message; } }
protected void getItems(int grpCatId) { try { IAdmin getItems = new AdminItems(); DataTable itemDT = getItems.getItems(grpCatId); if (itemDT != null) { itemGrid.DataSource = itemDT; itemGrid.DataBind(); } else { lbl_status.Text = "No Data for items! change the catagory"; itemGrid.DataSource = null; itemGrid.DataBind(); } } catch (Exception iExp) { lbl_status.Text = "Error Occured: " + iExp.Message; } }
private void getItems(int grpCatId) { try { IAdmin getItems = new AdminItems(); DataTable itemDT = getItems.getItems(grpCatId); if (itemDT != null) { itemGrid.DataSource = itemDT; itemGrid.DataBind(); } else { grpMsgLbl.Text = HardCodedValues.BuddaResource.ItemsNull; itemGrid.DataSource = null; itemGrid.DataBind(); } } catch (Exception iExp) { grpMsgLbl.Text = HardCodedValues.BuddaResource.CatchBlockError + iExp.Message; } }
private void searchDT(string itemname, int catid) { try { IAdmin searchitemname = new AdminItems(); DataTable searchitemDT = searchitemname.SearchItems(itemname, catid); if (searchitemDT != null) { itemGrid.DataSource = searchitemDT; itemGrid.DataBind(); grpMsgLbl.Text = ""; } else { grpMsgLbl.Text = HardCodedValues.BuddaResource.NoItemError; itemGrid.DataSource = null; itemGrid.DataBind(); } } catch (Exception iExp) { grpMsgLbl.Text = HardCodedValues.BuddaResource.CatchBlockError + iExp.Message; } }
protected void itemGrid_RowDeleting(object sender, GridViewDeleteEventArgs e) { int itemid = Convert.ToInt32(itemGrid.DataKeys[e.RowIndex].Value.ToString()); IAdmin RemoveItem = new AdminItems(); int removed = RemoveItem.removeItems(itemid); if (removed == -1) { lbl_status.Text = "Item Removed"; if (txt_itemname.Text == "Enter Item Name/Id") { int grpCatId = Int32.Parse(ddl_catagory.SelectedValue.ToString()); getItems(grpCatId); } else { searchDT(txt_itemname.Text); } } else { lbl_status.Text = "Error Occured while Removing the Item, Try again"; } }
private void searchDT(string uname) { try { IAdmin searchusername = new AdminItems(); DataTable searchuserDT = searchusername.SearchUsers(uname); if (searchuserDT != null) { userGrid.DataSource = searchuserDT; userGrid.DataBind(); lbl_status.Text = ""; } else { lbl_status.Text = HardCodedValues.BuddaResource.UserNull; userGrid.DataSource = null; userGrid.DataBind(); } } catch (Exception iExp) { lbl_status.Text = HardCodedValues.BuddaResource.CatchBlockError + iExp.Message; } }
protected void searchDT(string itemname) { try { IAdmin searchitemname = new AdminItems(); DataTable searchitemDT = searchitemname.SearchItems(itemname); if (searchitemDT != null) { itemGrid.DataSource = searchitemDT; itemGrid.DataBind(); lbl_status.Text = ""; } else { lbl_status.Text = "No Items Found, Enter Existing Item Name"; itemGrid.DataSource = null; itemGrid.DataBind(); } } catch (Exception iExp) { lbl_status.Text = "Error Occured: " + iExp.Message; } }
protected void itemGrid_RowUpdating(object sender, GridViewUpdateEventArgs e) { int itemid = Convert.ToInt32(itemGrid.DataKeys[e.RowIndex].Value.ToString()); TextBox itemname = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_iname"); TextBox description = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_editidescr"); FileUpload fu_itemimage = (FileUpload)itemGrid.Rows[e.RowIndex].FindControl("fu_iimage"); TextBox catagoryid = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_cid"); TextBox billedrate = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_billedrate"); TextBox quantity = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_qty"); TextBox netrate = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_netrate"); CheckBox cb_actvsts = (CheckBox)itemGrid.Rows[e.RowIndex].FindControl("cb_actvstsedit"); CheckBox cb_featuredflag = (CheckBox)itemGrid.Rows[e.RowIndex].FindControl("cb_fflagedit"); TextBox txt_itemtype = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_type"); DropDownList ddl_SubCatId = (DropDownList)itemGrid.Rows[e.RowIndex].FindControl("ddl_subcatid"); DropDownList ddl_merchantId = (DropDownList)itemGrid.Rows[e.RowIndex].FindControl("ddl_merchantId"); //check whether the image is valid or not bool isImageValid = checkPhoto(fu_itemimage, Int32.Parse(catagoryid.Text), itemid); if (isImageValid) { //save updated values in database BusinessEntitiesBS.ItemEntities.ItemObj UpdateItemObj = new BusinessEntitiesBS.ItemEntities.ItemObj(); UpdateItemObj.itemName = itemname.Text; UpdateItemObj.itemDesc = description.Text; UpdateItemObj.itemCatagory = Int32.Parse(catagoryid.Text); UpdateItemObj.itemBR = float.Parse(billedrate.Text); UpdateItemObj.itemQty = Int32.Parse(quantity.Text); UpdateItemObj.itemNR = float.Parse(netrate.Text); UpdateItemObj.itemStatus = cb_actvsts.Checked; UpdateItemObj.featuredFlag = cb_featuredflag.Checked; UpdateItemObj.itemType = txt_itemtype.Text; UpdateItemObj.itemSubCatId = Int32.Parse(ddl_SubCatId.SelectedValue); UpdateItemObj.merchantId = Int32.Parse(ddl_merchantId.SelectedValue); IAdmin UpdateItems = new AdminItems(); int updated = UpdateItems.UpdateItems(UpdateItemObj, itemid); if (updated != -1) { lbl_status.Text = HardCodedValues.BuddaResource.UpdateSuccess; ClearCache(); itemGrid.EditIndex = -1; int grpCatId = Int32.Parse(ddl_catagory.SelectedValue.ToString()); if (txt_itemname.Text == "") { getItems(grpCatId); } else { searchDT(txt_itemname.Text, grpCatId); } } else { lbl_status.Text = HardCodedValues.BuddaResource.UpdateFail; } } else { lbl_status.Text = HardCodedValues.BuddaResource.ImageError; } }
protected void grpSubmitBtn_Click(object sender, EventArgs e) { bool flagItem; DataTable grpItemsDt = new DataTable(); DataColumn dc = new DataColumn("GrpItem", typeof(int)); grpItemsDt.Columns.Add(dc); foreach (GridViewRow dRow in itemGrid.Rows) { flagItem = (dRow.FindControl("itemChkBox") as CheckBox).Checked; if (flagItem) { int itemId = Convert.ToInt32(itemGrid.DataKeys[dRow.RowIndex].Value); DataRow dr = grpItemsDt.NewRow(); dr[0] = itemId; grpItemsDt.Rows.Add(dr); } } string grpItemString = ""; bool first = true; if (grpItemsDt.Rows.Count > 0) { foreach (DataRow iRow in grpItemsDt.Rows) { if (first) { grpItemString += int.Parse(iRow["GrpItem"].ToString()); first = false; } else { grpItemString += "," + int.Parse(iRow["GrpItem"].ToString()); } } BusinessEntitiesBS.GroupEntities.grpObj grpValus = new BusinessEntitiesBS.GroupEntities.grpObj(); grpValus.grpName = grpNameTxt.Text.ToString(); grpValus.grpDesc = grpDescTxt.Text.ToString(); grpValus.grpBR = float.Parse(grpBrTxt.Text.ToString()); grpValus.grpNR = float.Parse(grpNrTxt.Text.ToString()); grpValus.grpStatus = grpCb.Checked; grpValus.fixedGrp = grpStatusCb.Checked; grpValus.Quantity = Int32.Parse(grpQtyTxt.Text.ToString()); //item string grpValus.itemIdStr = grpItemString; IAdmin insertGroup = new AdminItems(); int grpId = insertGroup.insertGroup(grpValus); if (grpId != -1) { grpMsgLbl.Text = "Group Inserted"; } else { grpMsgLbl.Text = "Error Occured! Group not inserted"; } } else { grpMsgLbl.Text = "Select items for the group"; } }
protected void grpSubmitBtn_Click(object sender, EventArgs e) { if (grpImageFU.FileName != string.Empty && grpImageFU.FileContent.Length <= 1024000) { //bool flagItem; float billedrate = 0, netrate = 0; DataTable grpItemsDt = new DataTable(); DataColumn dc = new DataColumn("GrpItem", typeof(int)); grpItemsDt.Columns.Add(dc); foreach (GridViewRow dRow in SelectedItemGrid.Rows) { string nrate = dRow.Cells[4].Text.ToString(); string brate = dRow.Cells[3].Text.ToString(); billedrate += float.Parse(brate); netrate += float.Parse(nrate); int itemId = Convert.ToInt32(dRow.Cells[0].Text.ToString()); DataRow dr = grpItemsDt.NewRow(); dr[0] = itemId; grpItemsDt.Rows.Add(dr); } string grpItemString = ""; bool first = true; if (grpItemsDt.Rows.Count > 0) { foreach (DataRow iRow in grpItemsDt.Rows) { if (first) { grpItemString += int.Parse(iRow["GrpItem"].ToString()); first = false; } else { grpItemString += "," + int.Parse(iRow["GrpItem"].ToString()); } } float discount = float.Parse(grpDiscountTxt.Text); billedrate -= (billedrate * (discount / 100)); netrate = (netrate - (netrate * (discount / 100))); BusinessEntitiesBS.GroupEntities.grpObj grpValus = new BusinessEntitiesBS.GroupEntities.grpObj(); grpValus.grpName = grpNameTxt.Text.ToString(); grpValus.grpDesc = grpDescTxt.Text.ToString(); grpValus.grpBR = billedrate; grpValus.grpNR = netrate; //grpValus.grpBR = float.Parse(grpBrTxt.Text.ToString()); //grpValus.grpNR = float.Parse(grpNrTxt.Text.ToString()); grpValus.grpStatus = grpCb.Checked; grpValus.fixedGrp = grpStatusCb.Checked; grpValus.Quantity = Int32.Parse(grpQtyTxt.Text.ToString()); //item string grpValus.itemIdStr = grpItemString; IAdmin insertGroup = new AdminItems(); int grpId = insertGroup.insertGroup(grpValus); if (grpId != -1) { //create folder for item images and save images. show result string NewDir = Server.MapPath("~/GroupImages/" + "/" + grpId); try { // Check if directory exists if (!Directory.Exists(NewDir)) { // Create the directory. Directory.CreateDirectory(NewDir); } } catch (IOException _ex) { grpMsgLbl.Text = HardCodedValues.BuddaResource.FloderError + _ex.Message; } string filename = grpId + "Photo.jpg"; grpImageFU.SaveAs(Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + filename); string filePath = Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + filename; string newfileMed = grpId + "Photomedium.jpg"; string newfileSmall = grpId + "small.jpg"; string resizedImageMed = Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + newfileMed; string resizedImageSmall = Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + newfileSmall; System.Drawing.Image img = System.Drawing.Image.FromFile(filePath); System.Drawing.Bitmap bmpD = img as Bitmap; Bitmap bmpDriverMed = new Bitmap(bmpD, 500, 500); bmpDriverMed.Save(resizedImageMed, System.Drawing.Imaging.ImageFormat.Jpeg); Bitmap bmpDriverSmall = new Bitmap(bmpD, 150, 150); bmpDriverSmall.Save(resizedImageSmall, System.Drawing.Imaging.ImageFormat.Jpeg); grpMsgLbl.Text = HardCodedValues.BuddaResource.GroupAdd; } else { grpMsgLbl.Text = HardCodedValues.BuddaResource.GroupNotAdded; } } else { grpMsgLbl.Text = HardCodedValues.BuddaResource.ItemSelect; } } else { grpMsgLbl.Text = HardCodedValues.BuddaResource.ImageSizeError; } ClearCache(); }
protected void ItemBtn_Click(object sender, EventArgs e) { bool resFU = checkPhoto(itemImageFU); if (resFU) { try { BusinessEntitiesBS.ItemEntities.ItemObj itemValues = new BusinessEntitiesBS.ItemEntities.ItemObj(); itemValues.itemName = ItemTxt.Text; itemValues.itemDesc = descTxt.InnerText.ToString(); itemValues.itemCatagory = Int32.Parse(CatagoryDDL.SelectedValue); itemValues.itemImagePath = itemImageFU.FileName.ToString(); itemValues.itemQty = Int32.Parse(qtyTxt.Text); itemValues.itemBR = float.Parse(brateTxt.Text); itemValues.itemNR = float.Parse(netRateTxt.Text); itemValues.itemStatus = CheckBoxSts.Checked; itemValues.itemType = typeTxt.Text; itemValues.itemSubCatId = Int32.Parse(SubCatagoryDDL.SelectedValue); itemValues.merchantId = Int32.Parse(MerchantDDL.SelectedValue); IAdmin insertItem = new AdminItems(); int itemId = insertItem.insertItems(itemValues); if (itemId != -1) { //create folder for item images and save images. show result string NewDir = Server.MapPath("~/ItemImages/" + Int32.Parse(CatagoryDDL.SelectedValue) + "/" + itemId); try { // Check if directory exists if (!Directory.Exists(NewDir)) { // Create the directory. Directory.CreateDirectory(NewDir); } } catch (IOException _ex) { ItemMessageLbl.Text = HardCodedValues.BuddaResource.CatchBlockError + _ex.Message; } //string filename = Path.GetFileName(PhotoFU.FileName); string filename = itemId + "Photo.jpg"; itemImageFU.SaveAs(Server.MapPath("~/ItemImages/" + Int32.Parse(CatagoryDDL.SelectedValue) + "/" + itemId + "/") + filename); string filePath = Server.MapPath("~/ItemImages/" + Int32.Parse(CatagoryDDL.SelectedValue) + "/" + itemId + "/") + filename; string newfileMed = itemId + "Photomedium.jpg"; string newfileSmall = itemId + "small.jpg"; string resizedImageMed = Server.MapPath("~/ItemImages/" + Int32.Parse(CatagoryDDL.SelectedValue) + "/" + itemId + "/") + newfileMed; string resizedImageSmall = Server.MapPath("~/ItemImages/" + Int32.Parse(CatagoryDDL.SelectedValue) + "/" + itemId + "/") + newfileSmall; System.Drawing.Image img = System.Drawing.Image.FromFile(filePath); System.Drawing.Bitmap bmpD = img as Bitmap; Bitmap bmpDriverMed = new Bitmap(bmpD, 500, 500); bmpDriverMed.Save(resizedImageMed, System.Drawing.Imaging.ImageFormat.Jpeg); Bitmap bmpDriverSmall = new Bitmap(bmpD, 150, 150); bmpDriverSmall.Save(resizedImageSmall, System.Drawing.Imaging.ImageFormat.Jpeg); ItemMessageLbl.Text = HardCodedValues.BuddaResource.ItemAdd; } else { ItemMessageLbl.Text = HardCodedValues.BuddaResource.AddItemFail; } ClearCache(); } catch (Exception iExp) { ItemMessageLbl.Text = HardCodedValues.BuddaResource.CatchBlockError + iExp.Message; } } }