コード例 #1
0
        public int UpdateItems(BusinessEntitiesBS.ItemEntities.ItemObj updateitemObj, int itemid)
        {
            IAdminDA UpdateItemValues = new DataAccessBS.AdminClasses.AdminDA();

            int updateitemId = UpdateItemValues.UpdateItemDA(updateitemObj, itemid);

            return(updateitemId);
        }
コード例 #2
0
        public int insertItems(BusinessEntitiesBS.ItemEntities.ItemObj itemObj)
        {
            IAdminDA itemValues = new DataAccessBS.AdminClasses.AdminDA();

            int itemId = itemValues.insertItemDA(itemObj);

            return(itemId);
        }
コード例 #3
0
        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");

            //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);

                IAdmin UpdateItems = new AdminItems();
                int    updated     = UpdateItems.UpdateItems(UpdateItemObj, itemid);
                if (updated != -1)
                {
                    lbl_status.Text    = "Updated Successfully";
                    itemGrid.EditIndex = -1;
                    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.. Row Not Updated";
                }
            }
            else
            {
                lbl_status.Text = "Selected file is not an image or it is greater than 1mb";
            }
        }
コード例 #4
0
        public int insertItemDA(BusinessEntitiesBS.ItemEntities.ItemObj itemObjDa)
        {
            try
            {
                SqlParameter[] sqlParams = new SqlParameter[10];

                //Catgory parameters
                sqlParams[0] = new SqlParameter("@itemName", itemObjDa.itemName);
                sqlParams[1] = new SqlParameter("@itemDescription", itemObjDa.itemDesc);
                sqlParams[2] = new SqlParameter("@catId", itemObjDa.itemCatagory);
                sqlParams[3] = new SqlParameter("@itemBR", itemObjDa.itemBR);
                sqlParams[4] = new SqlParameter("@itemNR", itemObjDa.itemNR);
                sqlParams[5] = new SqlParameter("@itemQty", itemObjDa.itemQty);
                sqlParams[6] = new SqlParameter("@itemSts", itemObjDa.itemStatus);
                sqlParams[7] = new SqlParameter("@itemType", itemObjDa.itemType);
                sqlParams[8] = new SqlParameter("@subCatId", itemObjDa.itemSubCatId);
                sqlParams[9] = new SqlParameter("@merchantId", itemObjDa.merchantId);

                DataTable idDt       = DBHelper.ExecuteDataset(DBCommon.ConnectionString, "USP_INSERT_ITEMS", sqlParams).Tables[0];
                int       returnedId = Convert.ToInt32(idDt.Rows[0].ItemArray[0].ToString());

                //string imgPath = "/ItemImages/" + itemObjDa.itemCatagory+"/"+returnedId+ "/" +returnedId+"small.jpg";

                //SqlParameter[] imgSqlParams = new SqlParameter[2];
                //imgSqlParams[0] = new SqlParameter("@itemID", returnedId);
                //imgSqlParams[1] = new SqlParameter("@itemImagePath", imgPath);

                // int retImgPth = DBHelper.ExecuteNonQuery(DBCommon.ConnectionString, "USP_INSERT_ITEM_IMAGEPATH", imgSqlParams);

                if (idDt.Rows.Count > 0)
                {
                    return(returnedId);
                }
                else
                {
                    return(-1);
                }
            }
            catch (SqlException exc)
            {
                return(-1);

                throw exc;
            }
        }
コード例 #5
0
        public int UpdateItemDA(BusinessEntitiesBS.ItemEntities.ItemObj updateitemObjDa, int itemid)
        {
            try
            {
                SqlParameter[] sqlParams = new SqlParameter[12];

                //Catgory parameters
                sqlParams[0]  = new SqlParameter("@itemId", itemid);
                sqlParams[1]  = new SqlParameter("@itemName", updateitemObjDa.itemName);
                sqlParams[2]  = new SqlParameter("@itemDescription", updateitemObjDa.itemDesc);
                sqlParams[3]  = new SqlParameter("@catId", updateitemObjDa.itemCatagory);
                sqlParams[4]  = new SqlParameter("@itemBR", updateitemObjDa.itemBR);
                sqlParams[5]  = new SqlParameter("@itemNR", updateitemObjDa.itemNR);
                sqlParams[6]  = new SqlParameter("@itemQty", updateitemObjDa.itemQty);
                sqlParams[7]  = new SqlParameter("@itemSts", updateitemObjDa.itemStatus);
                sqlParams[8]  = new SqlParameter("@featuredFlag", updateitemObjDa.featuredFlag);
                sqlParams[9]  = new SqlParameter("@itemType", updateitemObjDa.itemType);
                sqlParams[10] = new SqlParameter("@subCatId", updateitemObjDa.itemSubCatId);
                sqlParams[11] = new SqlParameter("@merchantId", updateitemObjDa.merchantId);

                int updated = DBHelper.ExecuteNonQuery(DBCommon.ConnectionString, "USP_UPDATE_ITEMS", sqlParams);

                if (updated > 0)
                {
                    return(updated);
                }
                else
                {
                    return(-1);
                }
            }
            catch (SqlException exc)
            {
                return(-1);

                throw exc;
            }
        }
コード例 #6
0
        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;
                }
            }
        }
コード例 #7
0
        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;
            }
        }
コード例 #8
0
        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;
                }

            }
        }
コード例 #9
0
        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");

            //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);

                IAdmin UpdateItems = new AdminItems();
                int updated = UpdateItems.UpdateItems(UpdateItemObj, itemid);
                if (updated != -1)
                {
                    lbl_status.Text = "Updated Successfully";
                    itemGrid.EditIndex = -1;
                    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.. Row Not Updated";
                }
            }
            else
            {
                lbl_status.Text = "Selected file is not an image or it is greater than 1mb";
            }
        }
コード例 #10
0
        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;
            }
        }