Example #1
0
    //handle delete event
    protected void imgbtnDelete_Click(object sender, EventArgs e)
    {
        productManager objproduct = new productManager();

        try
        {
            int      con        = 0;
            CheckBox chk        = new CheckBox();
            string   ActImage   = string.Empty;
            string   ThumbImage = string.Empty;
            DataSet  dsadmin    = new DataSet();

            for (int i = 0; i < gvAdmin.Rows.Count; i++)
            {
                chk = (CheckBox)(gvAdmin.Rows[i].FindControl("chkDelete"));
                if (chk.Checked == true)
                {
                    con += 1;
                    objproduct.productId = Convert.ToInt32(gvAdmin.DataKeys[gvAdmin.Rows[i].RowIndex].Value.ToString());
                    // objuser.DeleteAdminRightsItem();
                    objproduct.DeleteItem();
                    //Menu delete logic goes here
                    //if (System.IO.File.Exists(Server.MapPath("~") + "/admin/menu/" + objuser.adminid + ".htm"))
                    //{
                    //    System.IO.File.Delete(Server.MapPath("~") + "/admin/menu/" + objuser.adminid + ".htm");
                    //}
                }
            }
            Response.Redirect("viewinventory.aspx?flag=delete&key=" + txtsearch.Text + "");
            //Response.Redirect("viewinventory.aspx?flag=delete");
        }
        catch (Exception ex) { throw ex; }
        finally { objproduct = null; }
    }
Example #2
0
 protected void btnUpdateAll_Click(object sender, EventArgs e)
 {
     foreach (GridViewRow row in gvAdmin.Rows)
     {
         if (row.RowType == DataControlRowType.DataRow)
         {
             bool isChecked = row.Cells[0].Controls.OfType <CheckBox>().FirstOrDefault().Checked;
             if (isChecked)
             {
                 productManager objprodct = new productManager();
                 try
                 {
                     objprodct.productId = Convert.ToInt32(row.Cells[4].Controls.OfType <HiddenField>().FirstOrDefault().Value);
                     objprodct.inventory = Convert.ToInt32(row.Cells[4].Controls.OfType <TextBox>().FirstOrDefault().Text);
                     objprodct.UpdateInventory();
                     gvAdmin.EditIndex = -1;
                     //BindProduct();
                     lblmsg.Visible = true;
                     lblmsgs.Text   = "Product inventory updated successfully.";
                 }
                 catch (Exception ex)
                 {
                     throw ex;
                 }
                 finally { objprodct = null; }
             }
         }
     }
     BindProduct();
     lblmsg.Visible = true;
     lblmsgs.Text   = "Product inventory updated successfully.";
 }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        productManager objProduct = new productManager();
        ////insert image product
        HttpFileCollection uploadedFiles = Request.Files;

        for (int im = 0; im < uploadedFiles.Count; im++)
        {
            HttpPostedFile userPostedFile = uploadedFiles[im];
            string         name           = userPostedFile.FileName;
            if (name != "null" && name != "")
            {
                string extension = Path.GetExtension(userPostedFile.FileName).ToString();
                string name2     = name.Replace(extension, "");
                string nameBox   = Request.Form["newr" + name2];
                if (nameBox == null)
                {
                    objProduct.productId = 0;
                    objProduct.isactive  = 1;
                    objProduct.InsertProductImageItem();

                    int prodimageID = objProduct.GetmaximageProductId();
                    objProduct.productImagesId = prodimageID;
                    objProduct.actualImageName = userPostedFile.FileName;
                    objProduct.imageName       = UploadImage(userPostedFile, prodimageID);
                    objProduct.imgLabel        = objProduct.imageName;
                    objProduct.UpdateImage();
                }
                else
                {
                }
            }
        }
        BindProduct();
    }
Example #4
0
    public string BindPopImages(string productid)
    {
        productManager objProduct = new productManager();

        objProduct.productId = Convert.ToInt32(productid);
        List <productManager> lmp = new List <productManager>();
        DataTable             dt  = new DataTable();

        dt = objProduct.SelectProductImage();
        string strImg = string.Empty;

        if (dt.Rows.Count > 0)
        {
            strImg += "<ul>";
            foreach (DataRow dr in dt.Rows)
            {
                strImg += "<li id=\"" + dr["productImagesId"].ToString() + "\">";
                strImg += "<img src=\"../" + AppSettings.PRODUCT_MEDIUM_ROOTURL + dr["imageName"].ToString() + "\" width='100px' height='100px' /><br />";
                strImg += "<a href=\"javascript:void(0)\" onclick=\"DeleteProductImage(" + dr["productImagesId"].ToString() + ");\"> Delete </a>";
                strImg += "</li>";
            }
            strImg += "</ul>";
        }
        return(strImg);
    }
Example #5
0
    public string UpdateProductImageSetMain(string productimageid)
    {
        productManager objpro = new productManager();
        int            ids    = 0;

        if (productimageid != "0" || productimageid == "")
        {
            objpro.productImagesId = Convert.ToInt32(productimageid);
            ids = objpro.getProductidFromProductimageId();
            if (ids != 0)
            {
                objpro.productId = ids;
                objpro.mainImage = Convert.ToChar("N");
                objpro.UpdateProductImageSetMainByProductid();
            }
            objpro.mainImage = Convert.ToChar("M");
            objpro.UpdateProductImageByProductImageIdSetMain();
            int count = objpro.getImagesCountByProductID();

            return(Convert.ToString(count));
        }
        else
        {
            return("fail");
        }
    }
Example #6
0
        static void Main(string[] args)
        {
            Product product1 = new Product();

            product1.Id           = 1;
            product1.CategoryId   = 2;
            product1.ProductName  = "Masa";
            product1.UnitPrice    = 500;
            product1.UnitsInStock = 3;

            Product product2 = new Product {
                Id           = 2, CategoryId = 5,
                UnitsInStock = 5, ProductName = "Kalem", UnitPrice = 35
            };


            //PascalCase                //CamelCase  //case sensitive
            productManager productmanager = new productManager();

            productManager.Add(product1);

            // int double bool .... deger tip
            // diziler class abstarct class interface ... referans tip
            //ref out

            productManager.Topla2(3, 6);

            int toplamaSonucu = productManager.Topla(3, 6);

            Console.WriteLine(toplamaSonucu * 2);
        }
Example #7
0
    public void addMasterProduct(string productName, string sku, string productDescription)
    {
        productManager objproduct = new productManager();

        if (productName != "" && sku != "" && productDescription != "")
        {
            objproduct.productName        = productName;
            objproduct.sku                = sku;
            objproduct.productDescription = productDescription;
            objproduct.barcode            = "";
            objproduct.isVarientProduct   = 0;
            objproduct.isMasterProduct    = 1;
            objproduct.price              = 0;
            objproduct.cost               = 0;
            objproduct.minimumQuantity    = 0;
            objproduct.inventory          = 0;
            objproduct.isactive           = 0;
            objproduct.isFeatured         = 0;

            objproduct.InsertItem();

            //return "success";
        }
        else
        {
            //return "fail";
        }
    }
Example #8
0
    public string DeleteProductImage(string productimageid)
    {
        productManager objpro = new productManager();

        if (productimageid != "0" || productimageid == "")
        {
            objpro.productImagesId = Convert.ToInt32(productimageid);
            string strImg = objpro.getProductImageName();
            if (strImg != "")
            {
                string fullimagepath      = string.Empty;
                string thumbimagepath     = string.Empty;
                string mediumimagepath    = string.Empty;
                string thumbrectimagepath = string.Empty;

                fullimagepath      = Server.MapPath(AppSettings.PRODUCT_ACTULE_ROOTURL + strImg);
                thumbimagepath     = Server.MapPath(AppSettings.PRODUCT_THUMB_ROOTURL + strImg);
                mediumimagepath    = Server.MapPath(AppSettings.PRODUCT_MEDIUM_ROOTURL + strImg);
                thumbrectimagepath = Server.MapPath(AppSettings.PRODUCT_THUMBRECT_ROOTURL + strImg);

                CommonFunctions.DeleteFile(fullimagepath);
                CommonFunctions.DeleteFile(thumbimagepath);
                CommonFunctions.DeleteFile(mediumimagepath);
                CommonFunctions.DeleteFile(thumbrectimagepath);
            }

            objpro.DeleteProductImageByProductImageId();

            return("success");
        }
        else
        {
            return("fail");
        }
    }
    protected void ImgBtnDelete_Click(object sender, ImageClickEventArgs e)
    {
        productManager objprodelete = new productManager();
        ImageButton    lnkRemove    = (ImageButton)sender;

        objprodelete.productImagesId = Convert.ToInt32(lnkRemove.CommandArgument);

        string dtimgs = objprodelete.getProductImageName();

        if (dtimgs != "")
        {
            string fullimagepath      = string.Empty;
            string thumbimagepath     = string.Empty;
            string mediumimagepath    = string.Empty;
            string thumbrectimagepath = string.Empty;

            fullimagepath      = Server.MapPath(AppSettings.PRODUCT_ACTULE_ROOTURL + dtimgs);
            thumbimagepath     = Server.MapPath(AppSettings.PRODUCT_THUMB_ROOTURL + dtimgs);
            mediumimagepath    = Server.MapPath(AppSettings.PRODUCT_MEDIUM_ROOTURL + dtimgs);
            thumbrectimagepath = Server.MapPath(AppSettings.PRODUCT_THUMBRECT_ROOTURL + dtimgs);

            CommonFunctions.DeleteFile(fullimagepath);
            CommonFunctions.DeleteFile(thumbimagepath);
            CommonFunctions.DeleteFile(mediumimagepath);
            CommonFunctions.DeleteFile(thumbrectimagepath);
        }

        objprodelete.DeleteProductImageByProductImageId();
        BindProduct();
        lblmsg.Visible = true;
        lblmsgs.Text   = "Product image has been deleted successfully";
    }
Example #10
0
    protected void gvAdmin_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        string  productid = gvAdmin.DataKeys[e.RowIndex].Values["productId"].ToString();
        TextBox inventory = (TextBox)gvAdmin.Rows[e.RowIndex].FindControl("txtInventory");

        productManager objprodct = new productManager();

        try
        {
            objprodct.inventory = Convert.ToInt32(inventory.Text);
            objprodct.productId = Convert.ToInt32(productid);
            objprodct.UpdateInventory();
            gvAdmin.EditIndex = -1;
            BindCustomer();
            lblmsg.Visible = true;
            lblmsgs.Text   = "Product inventory updated successfully.";
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally { objprodct = null; }
        //con.Open();
        //SqlCommand cmd = new SqlCommand("update stores set stor_name='" + stor_name.Text + "', stor_address='" + stor_address.Text + "', city='" + city.Text + "', state='" + state.Text + "', zip='" + zip.Text + "' where stor_id=" + stor_id, con);
        //cmd.ExecuteNonQuery();
        //con.Close();
        //lblmsg.BackColor = Color.Blue;
        //lblmsg.ForeColor = Color.White;
        //lblmsg.Text = stor_id + "        Updated successfully........    ";
        //gridView.EditIndex = -1;
        //loadStores();
    }
Example #11
0
    public int GetProdutctidCount(string skuname)
    {
        productManager objpro = new productManager();

        objpro.sku = skuname;
        int Productid = Convert.ToInt32(objpro.GetProdutctidCount());

        return(Productid);
    }
Example #12
0
    protected void lnkStatus_click(object sender, EventArgs e)
    {
        productManager objpro = new productManager();
        GridViewRow    row    = ((LinkButton)sender).Parent.Parent as GridViewRow;

        objpro.isactive = Convert.ToByte(Convert.ToInt32(((LinkButton)sender).CommandArgument) == 0 ? 1 : 0);

        objpro.productId = Convert.ToInt32(gvAdmin.DataKeys[gvAdmin.Rows[row.RowIndex].RowIndex].Value.ToString());
        objpro.UpdateStatus();
        BindProduct();
        //trmsg.Visible = true;
        //lblmsgs.Text = "Admin Menu details are updated successfully";
    }
    // gridview events
    protected void gvAdmin_DataBound(object sender, EventArgs e)
    {
        foreach (GridViewRow row in gvAdmin.Rows)
        {
            int key = (int)gvAdmin.DataKeys[row.RowIndex].Value;
            if (row.RowType == DataControlRowType.DataRow)
            {
                DropDownList ddlSkus = (DropDownList)row.FindControl("ddlsku");

                productManager objprod = new productManager();
                DataTable      dt      = new DataTable();
                dt = objprod.BindAllSkuDDL();
                try
                {
                    if (dt.Rows.Count > 0)
                    {
                        ddlSkus.DataSource     = dt;
                        ddlSkus.DataTextField  = "sku";
                        ddlSkus.DataValueField = "productid";
                        ddlSkus.DataBind();

                        Label sku       = (Label)row.FindControl("hidsku");
                        Label productid = (Label)row.FindControl("lblProductid");
                        if (sku.Text != null && sku.Text != "")
                        {
                            //ddlSkus.SelectedItem.Text = sku.Text;
                            ddlSkus.SelectedValue = productid.Text;
                        }
                        else
                        {
                            ddlSkus.Items.Insert(0, new ListItem(" search ", "0"));
                        }

                        //ddlSkus.Items.Insert(0, new ListItem("Select", "0"));
                    }
                    else
                    {
                        ddlSkus.Items.Insert(0, new ListItem(" search ", "0"));
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally { objprod = null; dt = null; }
            }
        }
    }
Example #14
0
    public List <productManager> SKUBind()
    {
        productManager        objProduct = new productManager();
        List <productManager> lmp        = new List <productManager>();
        DataTable             dt         = new DataTable();

        dt = objProduct.SKUBind();
        foreach (DataRow dr in dt.Rows)
        {
            productManager PMS = new productManager();
            PMS.productId = Convert.ToInt32(dr["productid"].ToString());
            PMS.sku       = dr["sku"].ToString();
            lmp.Add(PMS);
        }
        return(lmp);
    }
    //handle delete event
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        productManager objproduct = new productManager();

        try
        {
            int      con        = 0;
            CheckBox chk        = new CheckBox();
            string   ActImage   = string.Empty;
            string   ThumbImage = string.Empty;
            DataSet  dsadmin    = new DataSet();

            for (int i = 0; i < gvAdmin.Rows.Count; i++)
            {
                chk = (CheckBox)(gvAdmin.Rows[i].FindControl("chkDelete"));
                if (chk.Checked == true)
                {
                    con += 1;
                    objproduct.productImagesId = Convert.ToInt32(gvAdmin.DataKeys[gvAdmin.Rows[i].RowIndex].Value.ToString());

                    string dtimgs = objproduct.getProductImageName();
                    if (dtimgs != "")
                    {
                        string fullimagepath      = string.Empty;
                        string thumbimagepath     = string.Empty;
                        string mediumimagepath    = string.Empty;
                        string thumbrectimagepath = string.Empty;

                        fullimagepath      = Server.MapPath(AppSettings.PRODUCT_ACTULE_ROOTURL + dtimgs);
                        thumbimagepath     = Server.MapPath(AppSettings.PRODUCT_THUMB_ROOTURL + dtimgs);
                        mediumimagepath    = Server.MapPath(AppSettings.PRODUCT_MEDIUM_ROOTURL + dtimgs);
                        thumbrectimagepath = Server.MapPath(AppSettings.PRODUCT_THUMBRECT_ROOTURL + dtimgs);

                        CommonFunctions.DeleteFile(fullimagepath);
                        CommonFunctions.DeleteFile(thumbimagepath);
                        CommonFunctions.DeleteFile(mediumimagepath);
                        CommonFunctions.DeleteFile(thumbrectimagepath);
                    }

                    objproduct.DeleteProductImageByProductImageId();
                }
            }
            Response.Redirect("ProductImageUpload.aspx?flag=delete&key=" + txtsearch.Text + "  &pageSize=" + ddlpageSize.SelectedValue + "");
        }
        catch (Exception ex) { throw ex; }
        finally { objproduct = null; }
    }
Example #16
0
    public string SkuIsExist(string prodid, string skuname)
    {
        productManager objproduct = new productManager();

        if (skuname != "")
        {
            objproduct.productId = Convert.ToInt32(prodid);
            objproduct.sku       = Convert.ToString(skuname);
            string checkexist = string.Empty;
            checkexist = objproduct.SkuIsExist();

            return(checkexist);
        }
        else
        {
            return("fail");
        }
    }
Example #17
0
    public void getErrorList()
    {
        productManager objpro = new productManager();
        DataTable      dt     = new DataTable();

        objpro.ImportFileId = Convert.ToInt32(Request.QueryString["id"]);
        dt = objpro.GetAllTempErrorByImportFileId();
        if (dt.Rows.Count > 0)
        {
            string strError = string.Empty;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                strError += "<b>Line: </b> " + dt.Rows[i]["BoolErrorLine"] + " <b>Column: </b> " + Server.HtmlDecode(dt.Rows[i]["BoolError"].ToString()) + "</br>";
            }
            ltrunread.Text = "Unreadable Data Found : ";
            //lblerrorlist.Text = "Unreadable Data Found : <b>Line: </b> " + dt.Rows[0]["BoolErrorLine"] + " <b>Column: </b> " + Server.HtmlDecode(dt.Rows[0]["BoolError"].ToString());
            lblerrorlist.Text = strError;
        }
    }
Example #18
0
    public List <productManager> MasterproductNameBind(string productname)
    {
        productManager objProduct = new productManager();

        objProduct.productName = Convert.ToString(productname);
        List <productManager> MPN = new List <productManager>();
        DataTable             dt  = new DataTable();

        dt = objProduct.MasterproductBindWithName();
        foreach (DataRow dr in dt.Rows)
        {
            productManager PM = new productManager();
            PM.productId   = Convert.ToInt32(dr["productid"].ToString());
            PM.productName = dr["productname"].ToString();
            PM.sku         = dr["sku"].ToString();
            MPN.Add(PM);
        }

        return(MPN);
    }
Example #19
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        productManager objproduct = new productManager();

        if (Page.IsValid)
        {
            string extension = Path.GetExtension(fluUploadCsv.FileName).ToLower();
            if (extension == ".csv")
            {
                string filetype    = "csv";
                bool   isValidFile = false;

                string        fileUploadLocation   = string.Empty;
                DirectoryInfo dirInfo              = null;
                string        uploadedFileName     = string.Empty;
                string        uploadedFileFullPath = string.Empty;

                string PhysicalPath = Server.MapPath("../" + System.Configuration.ConfigurationManager.AppSettings["ErrorUploadRootPath"].ToString());
                fileUploadLocation = (PhysicalPath);
                dirInfo            = new DirectoryInfo(fileUploadLocation);
                if (!dirInfo.Exists)
                {
                    dirInfo.Create();
                }

                uploadedFileName     = fluUploadCsv.FileName;
                uploadedFileFullPath = (fileUploadLocation + "\\") + uploadedFileName;
                fluUploadCsv.PostedFile.SaveAs(uploadedFileFullPath);
                //Dim headers As String() = csv.GetFieldHeaders()
                isValidFile = newvalidateCSVandTXTFiles_Automation(uploadedFileFullPath, filetype);
                if (File.Exists(uploadedFileFullPath))
                {
                    File.Delete(uploadedFileFullPath);
                }
            }
            else
            {
                lblError.Text = "Please upload a valid csv file.";
            }
        }
    }
Example #20
0
    public List <string> KeyWordAutoPopuletProductName(string SearchKey)
    {
        productManager objpro = new productManager();

        objpro.productName = Convert.ToString(SearchKey);
        List <string> MPN = new List <string>();
        DataTable     dt  = new DataTable();

        dt = objpro.KeyWordAutoPopuletProductName();
        if (dt.Rows.Count > 0)
        {
            foreach (DataRow dr in dt.Rows)
            {
                MPN.Add(Server.HtmlDecode(dr["productname"].ToString()));
            }
        }
        else
        {
            MPN.Add("No record found");
        }
        return(MPN);
    }
Example #21
0
    public List <productManager> BindMasterProductdata(string id)
    {
        productManager objProduct = new productManager();

        objProduct.productId = Convert.ToInt32(id);
        List <productManager> lmp = new List <productManager>();
        DataTable             dt  = new DataTable();

        dt = objProduct.SelectSingleItemById();
        productManager PMS = new productManager();

        foreach (DataRow dr in dt.Rows)
        {
            PMS.sku                = dr["sku"].ToString();
            PMS.productName        = dr["productName"].ToString();
            PMS.productDescription = dr["productDescription"].ToString();
        }

        DataTable dt1 = new DataTable();

        dt1 = objProduct.GetProductNameAndDescriptionByLanguageid();
        if (dt1.Rows.Count > 1)
        {
            for (int i = 0; i < dt1.Rows.Count - 1; i++)
            {
                PMS.ArabicName        = dt1.Rows[i + 1]["ArabicName"].ToString();
                PMS.ArabicDescription = dt1.Rows[i + 1]["ArabicDescription"].ToString();
                lmp.Add(PMS);
            }
        }
        else
        {
            PMS.ArabicName        = "";
            PMS.ArabicDescription = "";
            lmp.Add(PMS);
        }

        return(lmp);
    }
Example #22
0
    public List <string> MasterproductName(string productname)
    {
        productManager objProduct = new productManager();

        objProduct.productName = Convert.ToString(productname);
        List <string> MPN = new List <string>();
        DataTable     dt  = new DataTable();

        dt = objProduct.BindMasterProductName();
        if (dt.Rows.Count > 0)
        {
            foreach (DataRow dr in dt.Rows)
            {
                MPN.Add(dr["productname"].ToString());
            }
        }
        else
        {
            MPN.Add("No Product Name Found");
        }

        return(MPN);
    }
Example #23
0
    public string BindLeftTagsProduct(string productid)
    {
        string         strid    = string.Empty;
        productManager objprodu = new productManager();
        DataTable      dt       = new DataTable();

        try
        {
            objprodu.productId = Convert.ToInt32(productid);
            dt = objprodu.SelectProductTag();
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        strid = dt.Rows[i]["tagName"].ToString();
                    }
                    else
                    {
                        strid += "," + dt.Rows[i]["tagName"].ToString();
                    }
                }
                return(strid);
            }
            else
            {
                return(strid);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally { dt.Dispose(); objprodu = null; }
    }
Example #24
0
    public List <string> BindAllSKU(string sku)
    {
        productManager objProduct = new productManager();

        objProduct.sku = Convert.ToString(sku);
        List <string> MPN = new List <string>();
        DataTable     dt  = new DataTable();

        dt = objProduct.BindAllSKU();

        if (dt.Rows.Count > 0)
        {
            foreach (DataRow dr in dt.Rows)
            {
                MPN.Add(dr["sku"].ToString());
            }
        }
        else
        {
            MPN.Add("No SKU Found");
        }

        return(MPN);
    }
Example #25
0
    //Bind product
    private void BindProduct(string search = "")
    {
        //this.Form.DefaultButton = imgbtnSearch.UniqueID;
        pageSize = Convert.ToInt32(2000);
        productManager objproduct = new productManager();
        DataSet        dtadmin    = new DataSet();

        try
        {
            if (txtSearchProduct.Text != "")
            {
                objproduct.productName = Server.HtmlEncode(txtSearchProduct.Text.Trim());
            }
            else
            {
                objproduct.productName = Server.HtmlEncode(txtSearchProduct.Text.Trim());
            }

            if (pageNo == 0)
            {
                pageNo = 1;
            }
            objproduct.pageNo         = pageNo;
            objproduct.pageSize       = pageSize;
            objproduct.SortExpression = SortExpression;

            dtadmin   = objproduct.SearchOrder();
            totalrecs = objproduct.TotalRecord;
            if (pageNo == 1)
            {
                objproduct.pageNo = 1;
                pageNo            = 1;
            }
            else if (pageNo == 0)
            {
                objproduct.pageNo = 1;
                pageNo            = 1;
            }
            else
            {
                objproduct.pageNo = (pageNo - 1) * pageSize;
            }
            objproduct.pageSize = pageSize;
            totalpages          = totalrecs / pageSize;
            if ((totalrecs % pageSize) > 0 && (totalrecs > pageSize))
            {
                totalpages += 1;
            }
            GVOrder.DataSource = dtadmin;
            GVOrder.DataBind();
            if (dtadmin.Tables[0].Rows.Count > 0)
            {
                int startRowOnPage = (GVOrder.PageIndex * GVOrder.PageSize) + 1;
                int lastRowOnPage  = startRowOnPage + GVOrder.Rows.Count - 1;
                int totalRows      = totalrecs;
                //ltrcountrecord.Text = "<div class=\"countdiv\">Showing " + startRowOnPage.ToString() + " to " + lastRowOnPage + " of " + totalRows + " entries</div>";
            }
            String strpaging = CommonFunctions.AdminPagingv2(totalpages, pageNo, querystring, "add_order.aspx");
            //ltrpaggingbottom.Text = strpaging;
        }
        catch (Exception ex) { throw ex; }
        finally { dtadmin.Dispose(); objproduct = null; }
    }
    //Bind product
    private void BindProduct(string search = "")
    {
        this.Form.DefaultButton = imgbtnSearch.UniqueID;

        productManager objproduct = new productManager();
        DataTable      dtadmin    = new DataTable();

        try
        {
            if (txtsearch.Text != "")
            {
                objproduct.sku = txtsearch.Text.Trim();
            }
            else
            {
                objproduct.sku = txtsearch.Text.Trim();
            }

            if (pageNo == 0)
            {
                pageNo = 1;
            }
            objproduct.pageNo         = pageNo;
            objproduct.pageSize       = pageSize;
            objproduct.SortExpression = SortExpression;
            querystring = "&pageSize=" + ddlpageSize.SelectedValue + "&key=" + txtsearch.Text;
            dtadmin     = objproduct.SearchProductImageItem();
            totalrecs   = objproduct.TotalRecord;
            if (pageNo == 1)
            {
                objproduct.pageNo = 1;
                pageNo            = 1;
            }
            else if (pageNo == 0)
            {
                objproduct.pageNo = 1;
                pageNo            = 1;
            }
            else
            {
                objproduct.pageNo = (pageNo - 1) * pageSize;
            }
            objproduct.pageSize = pageSize;
            totalpages          = totalrecs / pageSize;
            if ((totalrecs % pageSize) > 0 && (totalrecs > pageSize))
            {
                totalpages += 1;
            }
            gvAdmin.DataSource = dtadmin;
            gvAdmin.DataBind();
            if (dtadmin.Rows.Count > 0)
            {
                int startRowOnPage = (gvAdmin.PageIndex * gvAdmin.PageSize) + 1;
                int lastRowOnPage  = startRowOnPage + gvAdmin.Rows.Count - 1;
                int totalRows      = totalrecs;
                ltrcountrecord.Text = "<div class=\"countdiv\">Showing " + startRowOnPage.ToString() + " to " + lastRowOnPage + " of " + totalRows + " entries</div>";
            }
            String strpaging = CommonFunctions.AdminPagingv2(totalpages, pageNo, querystring, "productImageUpload.aspx");
            ltrpaggingbottom.Text = strpaging;
            //Ltrup.Text = strpaging;
            LoadDropDownList();
        }
        catch (Exception ex) { throw ex; }
        finally { dtadmin.Dispose(); objproduct = null; }
    }
Example #27
0
    private void GetTestPDF()
    {
        string         filename_temp = string.Empty;
        var            filename      = "";
        productManager objPress      = new productManager();
        DataTable      dt            = new DataTable();

        try
        {
            dt = objPress.GetAllTheProducts();

            if (string.IsNullOrEmpty(filename))
            {
                filename = DateTime.Now.ToString("_mmddyyyy_HHmmss") + ".pdf";
            }
            string strPath = Server.MapPath("~") + "/Resources/PDF/";
            if (!Directory.Exists(strPath))
            {
                Directory.CreateDirectory(strPath);
            }
            filename_temp = strPath + DateTime.Now.Ticks.ToString() + ".pdf";

            //iTextSharp.text.Document document = new iTextSharp.text.Document(new RectangleReadOnly(0f, 0f), 10f, 10f, 100f, 100f);

            //Font boldFont = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD);
            //Font ProductHead = new Font(Font.FontFamily.HELVETICA, 14, Font.NORMAL);

            Font boldFont    = new Font(FontFactory.GetFont("FiraSans-Light", 10, Font.BOLD));
            Font ProductHead = new Font(FontFactory.GetFont("FiraSans-Light", 14, Font.NORMAL));
            Font ContentFont = new Font(FontFactory.GetFont("FiraSans-Light", 10, Font.NORMAL));
            Font FntColor    = new Font(FontFactory.GetFont("FiraSans-Light", 10, BaseColor.WHITE));

            //Font FntColor = new Font(FontFactory.GetFont("HELVETICA", 13, BaseColor.WHITE);

            Rectangle pageSize = new Rectangle(PageSize.A4);
            pageSize.BackgroundColor = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#EFF0F1"));
            Document document = new Document(pageSize, 10, 10, 100, 100);
            //document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filename_temp, FileMode.Create));
            //PdfWriter.GetInstance(document, new FileStream(filename_temp, FileMode.Create));

            writer.PageEvent = new ITextEvents();

            document.Open();

            PdfPTable maintable = new PdfPTable(1);
            maintable.DefaultCell.Border = Rectangle.NO_BORDER;
            float[] Mainwidths = new float[] { 580f };
            maintable.SetWidthPercentage(Mainwidths, pageSize);

            PdfPTable table = new PdfPTable(3);
            table.DefaultCell.Border = Rectangle.NO_BORDER;
            float[] widths = new float[] { 10f, 35f, 70f };
            table.SetWidths(widths);
            table.DefaultCell.Padding = 5f;

            #region master product images and QR code

            PdfPCell tablecell1 = new PdfPCell();

            tablecell1               = new PdfPCell(new Phrase("Master Product Name", ProductHead));
            tablecell1.Colspan       = 3;
            tablecell1.PaddingBottom = 5f;
            tablecell1.PaddingTop    = 5f;
            tablecell1.Border        = 0;
            table.AddCell(tablecell1);

            // QR Code

            BaseColor bcolorImg = new BaseColor(255, 255, 255);

            iTextSharp.text.Image t1image = null;
            using (FileStream fs = new FileStream(Server.MapPath("~") + "/resources/PDFTEST/QR.jpg", FileMode.Open))
            {
                t1image = iTextSharp.text.Image.GetInstance(System.Drawing.Image.FromStream(fs), ImageFormat.Jpeg);
            }

            t1image.ScaleToFit(50, 50);
            t1image.Alignment = Element.ALIGN_CENTER;
            tablecell1        = new PdfPCell(t1image);
            tablecell1.HorizontalAlignment = Element.ALIGN_LEFT;
            tablecell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
            tablecell1.PaddingLeft         = 10;
            tablecell1.FixedHeight         = 150f;
            tablecell1.Border            = 0;
            tablecell1.BorderColorLeft   = BaseColor.LIGHT_GRAY;
            tablecell1.BorderWidthLeft   = .5f;
            tablecell1.BorderColorTop    = BaseColor.LIGHT_GRAY;
            tablecell1.BorderWidthTop    = .5f;
            tablecell1.BorderColorBottom = BaseColor.LIGHT_GRAY;
            tablecell1.BorderWidthBottom = .5f;
            tablecell1.BackgroundColor   = bcolorImg;
            table.AddCell(tablecell1);

            // Product Image

            iTextSharp.text.Image t1image1 = null;
            using (FileStream fs = new FileStream(Server.MapPath("~") + "/resources/PDFTEST/Product.jpg", FileMode.Open))
            {
                t1image1 = iTextSharp.text.Image.GetInstance(System.Drawing.Image.FromStream(fs), ImageFormat.Jpeg);
            }

            t1image1.ScaleToFit(80, 80);
            t1image1.Alignment             = Element.ALIGN_CENTER;
            tablecell1                     = new PdfPCell(t1image1);
            tablecell1.PaddingLeft         = 51;
            tablecell1.HorizontalAlignment = Element.ALIGN_LEFT;
            tablecell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
            tablecell1.PaddingRight        = 31;
            tablecell1.Border              = 0;
            tablecell1.BorderColorRight    = BaseColor.LIGHT_GRAY;
            tablecell1.BorderWidthRight    = .5f;
            tablecell1.BorderColorTop      = BaseColor.LIGHT_GRAY;
            tablecell1.BorderWidthTop      = .5f;
            tablecell1.BorderColorBottom   = BaseColor.LIGHT_GRAY;
            tablecell1.BorderWidthBottom   = .5f;
            tablecell1.BackgroundColor     = bcolorImg;
            table.AddCell(tablecell1);

            #endregion

            #region  Master products sub product details
            // master product with its product details
            BaseColor hcolor = new BaseColor(233, 82, 28);
            PdfPTable table1 = new PdfPTable(4);
            table1.DefaultCell.Border = Rectangle.NO_BORDER;

            PdfPCell cell1 = new PdfPCell();

            cell1                     = new PdfPCell(new Phrase("Item No", FntColor));
            cell1.Border              = 0;
            cell1.BackgroundColor     = hcolor;
            cell1.FixedHeight         = 25f;
            cell1.HorizontalAlignment = Element.ALIGN_CENTER;
            cell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell1.BorderColorLeft     = BaseColor.LIGHT_GRAY;
            cell1.BorderWidthLeft     = .5f;
            table1.AddCell(cell1);

            cell1                     = new PdfPCell(new Phrase("Varient", FntColor));
            cell1.Border              = 0;
            cell1.BackgroundColor     = hcolor;
            cell1.FixedHeight         = 25f;
            cell1.HorizontalAlignment = Element.ALIGN_CENTER;
            cell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell1);

            cell1                     = new PdfPCell(new Phrase("Qty.", FntColor));
            cell1.Border              = 0;
            cell1.BackgroundColor     = hcolor;
            cell1.FixedHeight         = 25f;
            cell1.HorizontalAlignment = Element.ALIGN_CENTER;
            cell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell1);

            cell1                     = new PdfPCell(new Phrase("Price", FntColor));
            cell1.Border              = 0;
            cell1.BackgroundColor     = hcolor;
            cell1.FixedHeight         = 25f;
            cell1.HorizontalAlignment = Element.ALIGN_CENTER;
            cell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell1.BorderColorRight    = BaseColor.LIGHT_GRAY;
            cell1.BorderWidthRight    = .5f;
            table1.AddCell(cell1);

            int count = 0;
            foreach (DataRow dr in dt.Rows)
            {
                BaseColor bcolor  = new BaseColor(239, 240, 241);
                BaseColor bcolor2 = new BaseColor(255, 255, 255);

                if (count == 0 || count % 2 == 0)
                {
                    cell1        = new PdfPCell(new Phrase(Convert.ToString(dr["productid"]), ContentFont));
                    cell1.Border = 0;
                    cell1.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
                    cell1.BackgroundColor     = bcolor2;
                    cell1.FixedHeight         = 25f;
                    cell1.BorderColorLeft     = BaseColor.LIGHT_GRAY;
                    cell1.BorderWidthLeft     = .5f;
                    table1.AddCell(cell1);

                    cell1        = new PdfPCell(new Phrase(Convert.ToString(dr["productid"]), ContentFont));
                    cell1.Border = 0;
                    cell1.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
                    cell1.BackgroundColor     = bcolor2;
                    cell1.FixedHeight         = 25f;
                    table1.AddCell(cell1);

                    cell1        = new PdfPCell(new Phrase(Convert.ToString(dr["productid"]), ContentFont));
                    cell1.Border = 0;
                    cell1.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
                    cell1.BackgroundColor     = bcolor2;
                    cell1.FixedHeight         = 25f;
                    table1.AddCell(cell1);

                    cell1        = new PdfPCell(new Phrase(Convert.ToString(dr["productid"]), ContentFont));
                    cell1.Border = 0;
                    cell1.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
                    cell1.BackgroundColor     = bcolor2;
                    cell1.FixedHeight         = 25f;
                    cell1.BorderColorRight    = BaseColor.LIGHT_GRAY;
                    cell1.BorderWidthRight    = .5f;
                    table1.AddCell(cell1);
                }
                else
                {
                    cell1        = new PdfPCell(new Phrase(Convert.ToString(dr["productid"]), ContentFont));
                    cell1.Border = 0;
                    cell1.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
                    cell1.FixedHeight         = 25f;
                    cell1.BackgroundColor     = bcolor;
                    cell1.BorderColorLeft     = BaseColor.LIGHT_GRAY;
                    cell1.BorderWidthLeft     = .5f;
                    table1.AddCell(cell1);

                    cell1        = new PdfPCell(new Phrase(Convert.ToString(dr["productid"]), ContentFont));
                    cell1.Border = 0;
                    cell1.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
                    cell1.FixedHeight         = 25f;
                    cell1.BackgroundColor     = bcolor;

                    table1.AddCell(cell1);

                    cell1        = new PdfPCell(new Phrase(Convert.ToString(dr["productid"]), ContentFont));
                    cell1.Border = 0;
                    cell1.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
                    cell1.FixedHeight         = 25f;
                    cell1.BackgroundColor     = bcolor;

                    table1.AddCell(cell1);

                    cell1        = new PdfPCell(new Phrase(Convert.ToString(dr["productid"]), ContentFont));
                    cell1.Border = 0;
                    cell1.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
                    cell1.FixedHeight         = 25f;
                    cell1.BackgroundColor     = bcolor;
                    cell1.BorderColorRight    = BaseColor.LIGHT_GRAY;
                    cell1.BorderWidthRight    = .5f;
                    table1.AddCell(cell1);
                }
                count++;
                if (count == 5)
                {
                    cell1                     = new PdfPCell(new Phrase("More Item here", ContentFont));
                    cell1.Colspan             = 4;
                    cell1.Border              = 0;
                    cell1.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell1.VerticalAlignment   = Element.ALIGN_MIDDLE;
                    cell1.FixedHeight         = 25f;
                    cell1.BackgroundColor     = bcolor;
                    cell1.BorderColorRight    = BaseColor.LIGHT_GRAY;
                    cell1.BorderWidthRight    = .5f;
                    cell1.BorderColorLeft     = BaseColor.LIGHT_GRAY;
                    cell1.BorderWidthLeft     = .5f;
                    cell1.BorderColorBottom   = BaseColor.LIGHT_GRAY;
                    cell1.BorderWidthBottom   = .5f;
                    table1.AddCell(cell1);

                    break;
                }
            }

            table.AddCell(table1);

            tablecell1         = new PdfPCell(new Phrase(""));
            tablecell1.Colspan = 3;
            //tablecell1.FixedHeight = 4f;
            tablecell1.Border = 0;
            table.AddCell(tablecell1);

            #endregion

            #region varient product
            // Verient product

            PdfPTable Maintable2 = new PdfPTable(1);
            Maintable2.DefaultCell.Border = Rectangle.NO_BORDER;
            PdfPCell Maincell2 = new PdfPCell();

            foreach (DataRow dr in dt.Rows)
            {
                PdfPTable table2 = new PdfPTable(3);
                table2.WidthPercentage    = 100;
                table2.DefaultCell.Border = Rectangle.NO_BORDER;
                float[] Table2widths = new float[] { 20f, 35f, 70f };
                table2.SetWidths(Table2widths);

                PdfPCell cell2 = new PdfPCell();

                BaseColor Vcolor    = new BaseColor(236, 240, 245);
                BaseColor bcolorVer = new BaseColor(255, 255, 255);
                BaseColor ctcolor   = new BaseColor(239, 240, 241);

                cell2                     = new PdfPCell(new Phrase(dr["productname"].ToString(), ProductHead));
                cell2.Border              = 0;
                cell2.Colspan             = 3;
                cell2.PaddingTop          = 10f;
                cell2.PaddingBottom       = 10f;
                cell2.PaddingLeft         = 5f;
                cell2.HorizontalAlignment = Element.ALIGN_LEFT;
                cell2.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell2.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell2.BackgroundColor     = bcolorVer;
                table2.AddCell(cell2);


                iTextSharp.text.Image t1image2 = null;
                using (FileStream fs = new FileStream(Server.MapPath("~") + "/resources/PDFTEST/QR.jpg", FileMode.Open))
                {
                    t1image2 = iTextSharp.text.Image.GetInstance(System.Drawing.Image.FromStream(fs), ImageFormat.Jpeg);
                }

                t1image2.ScaleToFit(50, 50);
                t1image2.Alignment = Element.ALIGN_CENTER;

                cell2                   = new PdfPCell(t1image2);
                cell2.Border            = 0;
                cell2.PaddingLeft       = 10;
                cell2.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell2.BackgroundColor   = bcolorVer;
                table2.AddCell(cell2);

                iTextSharp.text.Image t1image3 = null;
                using (FileStream fs = new FileStream(Server.MapPath("~") + "/resources/PDFTEST/Product.jpg", FileMode.Open))
                {
                    t1image3 = iTextSharp.text.Image.GetInstance(System.Drawing.Image.FromStream(fs), ImageFormat.Jpeg);
                }

                t1image3.ScaleToFit(70, 70);
                t1image3.Alignment = Element.ALIGN_CENTER;

                cell2                   = new PdfPCell(t1image3);
                cell2.Border            = 0;
                cell2.BackgroundColor   = bcolorVer;
                cell2.VerticalAlignment = Element.ALIGN_MIDDLE;
                table2.AddCell(cell2);

                // child table

                PdfPTable table2Child = new PdfPTable(3);
                table2Child.DefaultCell.Border  = Rectangle.NO_BORDER;
                table2Child.DefaultCell.Padding = 10;
                table2Child.WidthPercentage     = 100;

                PdfPCell cell2Child = new PdfPCell();
                cell2Child                   = new PdfPCell(new Phrase("Item No.", boldFont));
                cell2Child.Border            = 0;
                cell2Child.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell2Child.BackgroundColor   = ctcolor;
                table2Child.AddCell(cell2Child);

                cell2Child                   = new PdfPCell(new Phrase("Min Qty", boldFont));
                cell2Child.Border            = 0;
                cell2Child.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell2Child.BackgroundColor   = ctcolor;
                table2Child.AddCell(cell2Child);

                cell2Child                   = new PdfPCell(new Phrase("price", boldFont));
                cell2Child.Border            = 0;
                cell2Child.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell2Child.BackgroundColor   = ctcolor;
                table2Child.AddCell(cell2Child);

                cell2Child                   = new PdfPCell(new Phrase(Convert.ToString(dr["productid"]), ContentFont));
                cell2Child.Border            = 0;
                cell2Child.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell2Child.BackgroundColor   = ctcolor;
                table2Child.AddCell(cell2Child);

                cell2Child                   = new PdfPCell(new Phrase(Convert.ToString(dr["productid"]), ContentFont));
                cell2Child.Border            = 0;
                cell2Child.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell2Child.BackgroundColor   = ctcolor;
                table2Child.AddCell(cell2Child);

                cell2Child                   = new PdfPCell(new Phrase(Convert.ToString(dr["productid"]), ContentFont));
                cell2Child.Border            = 0;
                cell2Child.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell2Child.BackgroundColor   = ctcolor;
                table2Child.AddCell(cell2Child);

                table2.AddCell(table2Child);

                cell2                     = new PdfPCell(new Phrase(""));
                cell2.Border              = 0;
                cell2.Colspan             = 3;
                cell2.PaddingTop          = 10f;
                cell2.PaddingBottom       = 10f;
                cell2.PaddingLeft         = 5f;
                cell2.FixedHeight         = 25f;
                cell2.HorizontalAlignment = Element.ALIGN_LEFT;
                cell2.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell2.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell2.BackgroundColor     = bcolorVer;
                table2.AddCell(cell2);

                PdfPCell cell = new PdfPCell();
                cell.AddElement(table2);
                cell.BorderWidthBottom = .5f;
                cell.BorderColorBottom = BaseColor.LIGHT_GRAY;
                cell.BorderWidthLeft   = .5f;
                cell.BorderColorLeft   = BaseColor.LIGHT_GRAY;
                cell.BorderWidthTop    = .5f;
                cell.BorderColorTop    = BaseColor.LIGHT_GRAY;
                cell.BorderWidthRight  = .5f;
                cell.BorderColorRight  = BaseColor.LIGHT_GRAY;
                PdfPTable t1 = new PdfPTable(1);
                t1.AddCell(cell);
                Maintable2.AddCell(t1);

                //space
                Maincell2             = new PdfPCell(new Phrase(""));
                Maincell2.Colspan     = 1;
                Maincell2.Border      = 0;
                Maincell2.PaddingTop  = 5f;
                Maincell2.FixedHeight = 10f;
                Maintable2.AddCell(Maincell2);
            }

            #endregion

            #region Single product and next is also single product

            // single product

            PdfPTable Outertable3     = new PdfPTable(2);
            float[]   Table3Outwidths = new float[] { 50f, 50f };
            Outertable3.SetWidths(Table3Outwidths);
            Outertable3.DefaultCell.Border  = Rectangle.NO_BORDER;
            Outertable3.DefaultCell.Padding = 5f;
            PdfPCell Outercell3 = new PdfPCell();

            int cnt = 0;
            foreach (DataRow dr in dt.Rows)
            {
                BaseColor bcolorSing = new BaseColor(255, 255, 255);
                PdfPTable table3     = new PdfPTable(3);
                table3.WidthPercentage             = 100;
                table3.DefaultCell.BackgroundColor = bcolorSing;

                float[] Table3widths = new float[] { 15f, 25f, 25f };
                table3.SetWidths(Table3widths);
                table3.DefaultCell.Border = Rectangle.NO_BORDER;
                PdfPCell cell3 = new PdfPCell();

                cell3                     = new PdfPCell(new Phrase(Convert.ToString(dr["productname"]), ProductHead));
                cell3.Colspan             = 3;
                cell3.Border              = 0;
                cell3.PaddingRight        = 5f;
                cell3.FixedHeight         = 25f;
                cell3.HorizontalAlignment = Element.ALIGN_LEFT;
                cell3.BackgroundColor     = bcolorSing;
                table3.AddCell(cell3);

                iTextSharp.text.Image t1image3 = null;
                using (FileStream fs = new FileStream(Server.MapPath("~") + "/resources/PDFTEST/QR.jpg", FileMode.Open))
                {
                    t1image3 = iTextSharp.text.Image.GetInstance(System.Drawing.Image.FromStream(fs), ImageFormat.Jpeg);
                }
                t1image3.ScaleToFit(50, 50);
                t1image3.Alignment = Element.ALIGN_CENTER;
                cell3                     = new PdfPCell(t1image3);
                cell3.PaddingLeft         = 5;
                cell3.HorizontalAlignment = Element.ALIGN_LEFT;
                cell3.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell3.BackgroundColor     = bcolorSing;
                cell3.PaddingRight        = 5;
                cell3.Border              = 0;

                table3.AddCell(cell3);

                iTextSharp.text.Image t1image4 = null;
                using (FileStream fs = new FileStream(Server.MapPath("~") + "/resources/PDFTEST/Product.jpg", FileMode.Open))
                {
                    t1image4 = iTextSharp.text.Image.GetInstance(System.Drawing.Image.FromStream(fs), ImageFormat.Jpeg);
                }
                t1image4.ScaleToFit(70, 70);
                t1image4.Alignment = Element.ALIGN_CENTER;
                cell3                     = new PdfPCell(t1image4);
                cell3.PaddingLeft         = 5;
                cell3.HorizontalAlignment = Element.ALIGN_LEFT;
                cell3.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell3.BackgroundColor     = bcolorSing;
                //cell3.PaddingRight = 5;
                cell3.Border = 0;
                table3.AddCell(cell3);

                PdfPTable table3Child = new PdfPTable(1);
                table3Child.DefaultCell.Border = Rectangle.NO_BORDER;

                PdfPCell cell1Child = new PdfPCell();
                cell1Child                 = new PdfPCell(new Phrase("Price", boldFont));
                cell1Child.Border          = 0;
                cell1Child.FixedHeight     = 25f;
                cell1Child.BackgroundColor = bcolorSing;
                table3Child.AddCell(cell1Child);

                cell1Child                 = new PdfPCell(new Phrase(Convert.ToString(dr["productid"]), ContentFont));
                cell1Child.Border          = 0;
                cell1Child.FixedHeight     = 25f;
                cell1Child.BackgroundColor = bcolorSing;
                table3Child.AddCell(cell1Child);

                cell1Child                 = new PdfPCell(new Phrase("Min Qty", boldFont));
                cell1Child.Border          = 0;
                cell1Child.FixedHeight     = 25f;
                cell1Child.BackgroundColor = bcolorSing;
                table3Child.AddCell(cell1Child);

                cell1Child                 = new PdfPCell(new Phrase(Convert.ToString(dr["productid"]), ContentFont));
                cell1Child.Border          = 0;
                cell1Child.FixedHeight     = 25f;
                cell1Child.BackgroundColor = bcolorSing;
                table3Child.AddCell(cell1Child);

                cell1Child                 = new PdfPCell(new Phrase("Item No.", boldFont));
                cell1Child.Border          = 0;
                cell1Child.FixedHeight     = 25f;
                cell1Child.BackgroundColor = bcolorSing;
                table3Child.AddCell(cell1Child);

                cell1Child                 = new PdfPCell(new Phrase(Convert.ToString(dr["productid"]), ContentFont));
                cell1Child.Border          = 0;
                cell1Child.FixedHeight     = 25f;
                cell1Child.BackgroundColor = bcolorSing;
                table3Child.AddCell(cell1Child);

                table3.AddCell(table3Child);
                cell3.AddElement(table3);
                table3.AddCell(cell3);

                PdfPCell cell = new PdfPCell();
                cell.AddElement(table3);
                cell.BorderWidthBottom = .5f;
                cell.BorderColorBottom = BaseColor.LIGHT_GRAY;
                cell.BorderWidthLeft   = .5f;
                cell.BorderColorLeft   = BaseColor.LIGHT_GRAY;
                cell.BorderWidthTop    = .5f;
                cell.BorderColorTop    = BaseColor.LIGHT_GRAY;
                cell.BorderWidthRight  = .5f;
                cell.BorderColorRight  = BaseColor.LIGHT_GRAY;
                PdfPTable t1 = new PdfPTable(1);
                t1.AddCell(cell);
                Outertable3.AddCell(t1);

                cnt++;

                if (cnt == 2)
                {
                    // space
                    Outercell3             = new PdfPCell(new Phrase(""));
                    Outercell3.Colspan     = 2;
                    Outercell3.Border      = 0;
                    Outercell3.PaddingTop  = 15f;
                    Outercell3.FixedHeight = 15;
                    Outertable3.AddCell(Outercell3);

                    cnt = 0;
                }
            }

            #endregion



            maintable.AddCell(table);
            maintable.AddCell(table);
            maintable.AddCell(table);
            maintable.AddCell(Maintable2);
            maintable.AddCell(Outertable3);

            // writer.PageEvent = new Footer(); // footer

            document.Add(maintable);

            document.Close();

            Response.Clear();
            Response.ClearContent();
            Response.ClearHeaders();

            System.IO.FileInfo fileInfo = new System.IO.FileInfo(filename_temp);
            byte[]             bytes    = System.IO.File.ReadAllBytes(filename_temp);
            if (fileInfo.Exists)
            {
                this.Response.Clear();
                //this.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + hdpdfname.Value + "\"");
                this.Response.AddHeader("Content-Disposition", "attachment; filename=test.pdf");
                this.Response.AddHeader("Content-Length", fileInfo.Length.ToString());
                this.Response.ContentType = "application/pdf";
                this.Response.BinaryWrite(bytes);
                this.Response.Flush();
            }
        }
        catch (Exception ex) { throw ex; }
        finally { objPress = null; dt = null; }
    }
Example #28
0
    protected void imgbtnApproveJob_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow row in gvImportjob.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                bool isChecked = row.Cells[0].Controls.OfType <CheckBox>().FirstOrDefault().Checked;
                if (isChecked)
                {
                    string lblsku = row.Cells[1].Controls.OfType <Label>().FirstOrDefault().Text;
                    string Id     = row.Cells[2].Controls.OfType <Label>().FirstOrDefault().Text;

                    productManager objprodct = new productManager();
                    DataTable      dtpro     = new DataTable();
                    try
                    {
                        objprodct.sku = Convert.ToString(lblsku);
                        // get the data from temp table
                        objprodct.id = Convert.ToInt32(Id);
                        dtpro        = objprodct.GetSingleImportProductValue();

                        string productId        = null;
                        string productName      = null;
                        string sku              = null;
                        string isVarientProduct = null;
                        string categoryname     = null;
                        string brandname        = null;
                        string price            = null;
                        string minimumQuantity  = null;
                        string inventory        = null;


                        //errorMsg = string.Empty;
                        bool checkValid = false;

                        if (dtpro.Rows.Count > 0)
                        {
                            productName      = Convert.ToString(dtpro.Rows[0]["productname"]);
                            sku              = Convert.ToString(dtpro.Rows[0]["sku"]);
                            isVarientProduct = Convert.ToString(dtpro.Rows[0]["isvarientproduct"]);
                            categoryname     = Convert.ToString(dtpro.Rows[0]["categoryname"]);
                            brandname        = Convert.ToString(dtpro.Rows[0]["brandname"]);
                            price            = Convert.ToString(dtpro.Rows[0]["price"]);
                            minimumQuantity  = Convert.ToString(dtpro.Rows[0]["minimumquantity"]);
                            inventory        = Convert.ToString(dtpro.Rows[0]["inventory"]);

                            //checkValidDataProduct
                            if (Convert.ToByte(dtpro.Rows[0]["ismasterproduct"]) == Convert.ToByte(true))
                            {
                                checkValid = checkValidDataMasterProduct(productName, sku, categoryname, brandname);
                            }
                            else
                            {
                                if (isVarientProduct.ToLower() == "false") // single product
                                {
                                    checkValid = checkValidDataProduct(productName, sku, categoryname, brandname, price, minimumQuantity, inventory);
                                }
                                else
                                {
                                    checkValid = checkValidDataSinglsProduct(productName, sku, price, minimumQuantity, inventory);
                                }
                            }

                            if (checkValid == false)
                            {
                                objprodct.FileError           = errorMsg;
                                objprodct.FileErrorLineNumber = Convert.ToInt32(1);
                                objprodct.updateSingleImportProduct();
                            }
                            else
                            {
                                objprodct.productName        = Server.HtmlEncode(Convert.ToString(dtpro.Rows[0]["productname"]));
                                objprodct.productDescription = Server.HtmlEncode(Convert.ToString(dtpro.Rows[0]["productdescription"]));
                                objprodct.sku              = Convert.ToString(dtpro.Rows[0]["sku"]);
                                objprodct.barcode          = Convert.ToString(dtpro.Rows[0]["barcode"]);
                                objprodct.isVarientProduct = Convert.ToByte(dtpro.Rows[0]["isvarientproduct"]);
                                objprodct.varientItem      = Convert.ToString(dtpro.Rows[0]["varientItem"]);
                                if (Request.QueryString["filetp"] == "3")
                                {
                                    objprodct.isMasterProduct = Convert.ToByte(1);
                                }
                                else
                                {
                                    objprodct.isMasterProduct = Convert.ToByte(dtpro.Rows[0]["ismasterproduct"]);
                                }
                                objprodct.price           = Convert.ToDecimal(dtpro.Rows[0]["price"]);
                                objprodct.cost            = Convert.ToDecimal(dtpro.Rows[0]["cost"]);
                                objprodct.minimumQuantity = Convert.ToInt32(dtpro.Rows[0]["minimumquantity"]);
                                objprodct.inventory       = Convert.ToInt32(dtpro.Rows[0]["inventory"]);
                                objprodct.isactive        = Convert.ToByte(dtpro.Rows[0]["isactive"]);
                                objprodct.isFeatured      = Convert.ToByte(dtpro.Rows[0]["isfeatured"]);


                                int count = objprodct.GetProdutctidCount();
                                if (count > 0)
                                {
                                    objprodct.productId = Convert.ToInt32(count);
                                    objprodct.UpdateItem();
                                    objprodct.isStatus = Convert.ToByte(1);
                                    objprodct.UpdateTempTableStatus();
                                }
                                else
                                {
                                    objprodct.InsertItem();
                                    objprodct.isStatus = Convert.ToByte(1);
                                    objprodct.UpdateTempTableStatus();
                                }

                                objprodct.productId = Convert.ToInt32(count);

                                #region product language

                                objprodct.DeleteProductLanguage();

                                objprodct.languageId = Convert.ToInt32(1);
                                objprodct.InsertProductLanguageItem();

                                objprodct.languageId         = Convert.ToInt32(2);
                                objprodct.productName        = Convert.ToString(dtpro.Rows[0]["ArabicName"]);
                                objprodct.productDescription = Convert.ToString(dtpro.Rows[0]["ArabicDesc"]);
                                objprodct.InsertProductLanguageItem();

                                #endregion

                                // add master product in product master table
                                int master_proid = 0;
                                if (Convert.ToString(dtpro.Rows[0]["master_product_parent"]) != "")
                                {
                                    objprodct.masterProductName = Convert.ToString(dtpro.Rows[0]["master_product_parent"]);
                                    master_proid = objprodct.getMasterProductid();
                                }

                                // add brand in brand product table
                                int brand_id = 0;
                                if (Convert.ToString(dtpro.Rows[0]["brandname"]) != "")
                                {
                                    objprodct.brandname = Convert.ToString(dtpro.Rows[0]["brandname"]);
                                    brand_id            = objprodct.getBrandId();
                                }

                                // add category in product category table
                                int cat_id    = 0;
                                int sub_catid = 0;
                                objprodct.CategoryName    = Convert.ToString(dtpro.Rows[0]["categoryname"]);    // category name
                                objprodct.subcategoryname = Convert.ToString(dtpro.Rows[0]["subcategoryname"]); // sub category name

                                if (Convert.ToString(dtpro.Rows[0]["categoryname"]) != "")
                                {
                                    cat_id = Convert.ToInt32(objprodct.getCategoryId());
                                }
                                if (cat_id > 0)
                                {
                                    if (Convert.ToString(dtpro.Rows[0]["subcategoryname"]) != "")
                                    {
                                        objprodct.parentid = Convert.ToInt32(cat_id);
                                        sub_catid          = Convert.ToInt32(objprodct.GetCategoryidByParentID());
                                    }
                                }
                                else
                                {
                                    if (Convert.ToString(dtpro.Rows[0]["subcategoryname"]) != "")
                                    {
                                        objprodct.CategoryName = Convert.ToString(dtpro.Rows[0]["subcategoryname"]);
                                        cat_id = Convert.ToInt32(objprodct.getCategoryId());
                                    }
                                }

                                if (objprodct.productId > 0)
                                {
                                    //product language
                                    objprodct.languageId = 1;
                                    //objprodct.UpdateProductLanguage();

                                    //product
                                    objprodct.DeleteProductCategory();

                                    //if (sub_catid > 0) { objprodct.categoryId = sub_catid; } else { objprodct.categoryId = cat_id; }
                                    //objprodct.InsertProductCategroyItem();

                                    if (sub_catid > 0)
                                    {
                                        objprodct.categoryId = sub_catid; objprodct.InsertProductCategroyItem();
                                    }
                                    objprodct.categoryId = cat_id; objprodct.InsertProductCategroyItem();

                                    // brand
                                    if (brand_id > 0)
                                    {
                                        objprodct.DeleteProductBrand(); objprodct.barndId = brand_id; objprodct.InsertProductBrandItem();
                                    }

                                    //master product
                                    if (master_proid > 0)
                                    {
                                        objprodct.DeleteMasterProductLink(); objprodct.masterProductId = master_proid; objprodct.InsertMasterProductLinkItem();
                                    }
                                }
                                else
                                {
                                    objprodct.DeleteProductCategory();
                                    //objprodct.DeleteProductBrand();

                                    int product_id = objprodct.getmaxid();
                                    objprodct.productId = product_id;

                                    //product language
                                    objprodct.languageId = 1;  // productname,productdescription from upside to here
                                    objprodct.InsertProductLanguageItem();


                                    //product
                                    //if (sub_catid > 0) { objprodct.categoryId = sub_catid; } else { objprodct.categoryId = cat_id; }
                                    //objprodct.InsertProductCategroyItem();
                                    if (sub_catid > 0)
                                    {
                                        objprodct.categoryId = sub_catid; objprodct.InsertProductCategroyItem();
                                    }
                                    objprodct.categoryId = cat_id; objprodct.InsertProductCategroyItem();

                                    // brand
                                    if (brand_id > 0)
                                    {
                                        objprodct.barndId = brand_id; objprodct.InsertProductBrandItem();
                                    }

                                    // master product
                                    if (master_proid > 0)
                                    {
                                        objprodct.masterProductId = master_proid; objprodct.InsertMasterProductLinkItem();
                                    }
                                }

                                // update validation message in tempproduct
                                objprodct.FileError           = Server.HtmlEncode(errorMsg);
                                objprodct.FileErrorLineNumber = Convert.ToInt32(0);
                                objprodct.updateSingleImportProduct();
                            }
                        }

                        //gvAdmin.EditIndex = -1;
                        //BindContents();
                    }
                    catch (Exception ex)
                    {
                        //throw ex;
                    }
                    finally { objprodct = null; dtpro = null; }
                }
            }
        }
        BindContents();
        lblmsg.Visible = true;
        lblmsgs.Text   = "Approved job successfully";
    }
Example #29
0
    //handle row data bound
    protected void gvImportjob_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //int productid = Convert.ToInt32(gvImportjob.DataKeys[e.Row.RowIndex].Value);


            Label LblAction = new Label();
            LblAction = (Label)e.Row.FindControl("lblAction");

            HiddenField hidsku = new HiddenField();
            hidsku = (HiddenField)e.Row.FindControl("hidsku");

            Label lblstatus = new Label();
            lblstatus = (Label)e.Row.FindControl("lblstatus");

            HiddenField hiderrno = new HiddenField();
            hiderrno = (HiddenField)e.Row.FindControl("hiderrno");

            //hidsku

            productManager objproduct = new productManager();
            objproduct.sku = hidsku.Value;
            int cont = objproduct.GetProdutctidCount();
            if (cont > 0)
            {
                LblAction.Text = "Update";
            }
            else
            {
                LblAction.Text = "Insert";
            }

            Label lblErrorType = new Label();
            lblErrorType = (Label)e.Row.FindControl("lblErrorType");
            CheckBox chkDelete = (e.Row.FindControl("chkDelete") as CheckBox);
            //if (lblErrorType.Text == "1")
            if (lblErrorType.Text != "0")
            {
                lblstatus.Text    = hiderrno.Value;
                chkDelete.Enabled = false;
                chkDelete.Visible = false;
            }
            else
            {
                lblstatus.Text = "Not Started";
            }



            HiddenField hiddescp = new HiddenField();
            hiddescp = (HiddenField)e.Row.FindControl("hiddescp");

            Label lblDescription = new Label();
            lblDescription = (Label)e.Row.FindControl("lblDescription");

            if (hiderrno.Value != "0")
            {
                lblDescription.Text = hiddescp.Value;
                lblDescription.Style.Add("color", "red");
            }
            else
            {
                lblDescription.Text = "Passed Validation";
                lblDescription.Style.Add("color", "green");
            }

            HiddenField hidstatus = new HiddenField();
            hidstatus = (HiddenField)e.Row.FindControl("hidstatus");
            if (hidstatus.Value == "1")
            {
                lblstatus.Text = "Completed";
            }


            //if (hiderrno.Value == "0")
            //{
            //    //lblDescription.Text = "Check Validation";
            //    lblDescription.Text = hiddescp.Value;
            //}
            //else if (hiderrno.Value == "1")
            //{
            //    lblDescription.Text = hiddescp.Value;
            //    lblDescription.Style.Add("color", "red");
            //}
            //else
            //{
            //    lblDescription.Text = "Pass Validation";
            //    lblDescription.Style.Add("color", "green");
            //}
        }

        if (e.Row.RowType == DataControlRowType.Header)
        {
            //Call the GetSortColumnIndex helper method to determine the index of the column being sorted.
            int sortColumnIndex = GetSortColumnIndex();
            if (sortColumnIndex != -1)
            {
                //Call the AddSortImage helper method to add a sort direction image to the appropriate column header.
                AddSortImage(sortColumnIndex, e.Row);
            }
        }
    }
Example #30
0
    public string addMasterProduct(string productName, string sku, string productDescription, string ddlPopCategoryProduct, string ddlPopBrandProduct, string ArabicName, string ArabicDiscription)
    {
        productManager objproduct = new productManager();

        if (productName != "" && sku != "")
        {
            objproduct.productName        = Server.HtmlEncode(productName);
            objproduct.sku                = sku;
            objproduct.productDescription = Server.HtmlEncode(productDescription);
            objproduct.barcode            = "";
            objproduct.isVarientProduct   = 0;
            objproduct.isMasterProduct    = 1;
            objproduct.price              = 0;
            objproduct.cost               = 0;
            objproduct.minimumQuantity    = 0;
            objproduct.inventory          = 0;
            objproduct.varientItem        = "";
            objproduct.isactive           = 1;
            objproduct.isFeatured         = 0;
            objproduct.varientItem        = "";

            if (objproduct.SkuExist())
            {
                return("Product sku is already exist");
            }
            if (objproduct.TitleExist())
            {
                return("Product name is already exist");
            }

            objproduct.InsertItem();

            int maxid = objproduct.getmaxid();
            objproduct.productId = maxid;

            objproduct.QRCOde = UploadQRCode(sku);
            objproduct.UpdateQRCode();

            if (ddlPopCategoryProduct != null || ddlPopCategoryProduct != "0")
            {
                string[] PopCategory = ddlPopCategoryProduct.Split(',');
                for (int i = 0; i < PopCategory.Count(); i++)
                {
                    objproduct.categoryId = Convert.ToInt32(PopCategory[i]);
                    objproduct.InsertProductCategroyItem();
                }
            }
            if (ddlPopBrandProduct != null || ddlPopBrandProduct != "0")
            {
                string[] PopBrand = ddlPopBrandProduct.Split(',');
                for (int j = 0; j < PopBrand.Count(); j++)
                {
                    objproduct.productId = maxid;
                    objproduct.barndId   = Convert.ToInt32(PopBrand[j]);
                    objproduct.InsertProductBrandItem();
                }
            }

            objproduct.languageId = 1;
            objproduct.InsertProductLanguageItem();

            objproduct.languageId         = 2;
            objproduct.productName        = Server.HtmlEncode(ArabicName);
            objproduct.productDescription = Server.HtmlEncode(ArabicDiscription);
            objproduct.InsertProductLanguageItem();

            //int maxID = objproduct.getmaxid();

            return("Master product inserted successfully");
        }
        else
        {
            return("Master product not inserted");
        }
    }