コード例 #1
0
    private bool Delete(int intPKID)
    {
        bool retval = false;

        objProduct = new tblProduct();
        if (objProduct.IsProductInOrder(intPKID.ToString()))
        {
            return(retval);
        }

        if (objProduct.LoadByPrimaryKey(intPKID))
        {
            tblPixcelCode objPixelCode = new tblPixcelCode();
            objPixelCode.Where.AppProductId.Value = intPKID;
            objPixelCode.Query.Load();
            if (objPixelCode.RowCount > 0)
            {
                objPixelCode.DeleteAll();
                objPixelCode.Save();
            }
            objPixelCode = null;

            tblProductSubCategory objProductSubCategory = new tblProductSubCategory();
            objProductSubCategory.Where.AppProductID.Value = intPKID;
            objProductSubCategory.Query.Load();
            if (objProductSubCategory.RowCount > 0)
            {
                objProductSubCategory.DeleteAll();
                objProductSubCategory.Save();
            }
            objProductSubCategory = null;

            tblRelatedProduct objRelatedProduct = new tblRelatedProduct();
            objRelatedProduct.Where.AppProductID.Value = intPKID;
            objRelatedProduct.Query.Load();
            if (objRelatedProduct.RowCount > 0)
            {
                objRelatedProduct.DeleteAll();
                objRelatedProduct.Save();
            }
            objRelatedProduct = null;

            tblProductProperty objProductProperty = new tblProductProperty();
            objProductProperty.Where.AppProductID.Value = intPKID;
            objProductProperty.Query.Load();
            if (objProductProperty.RowCount > 0)
            {
                objProductProperty.DeleteAll();
                objProductProperty.Save();
            }
            objProductProperty = null;

            tblProductColor objProductColor = new tblProductColor();
            objProductColor.Where.AppProductID.Value = intPKID;
            objProductColor.Query.Load();
            if (objProductColor.RowCount > 0)
            {
                while (!(objProductColor.EOF))
                {
                    tblProductDetail objProductDetail = new tblProductDetail();
                    objProductDetail.Where.AppProductColorID.Value = objProductColor.AppProductColorID;
                    objProductDetail.Query.Load();
                    if (objProductDetail.RowCount > 0)
                    {
                        objProductDetail.DeleteAll();
                        objProductDetail.Save();
                    }
                    objProductDetail = null;

                    tblProductImage objProductImage = new tblProductImage();
                    objProductImage.Where.AppProductColorID.Value = objProductColor.AppProductColorID;
                    objProductImage.Query.Load();
                    if (objProductImage.RowCount > 0)
                    {
                        //while(! objProductImage.EOF )
                        //{
                        //    if (System.IO.File.Exists(Server.MapPath(objProductImage.s_AppLargeImage )))
                        //    {
                        //        System.IO.File.Delete(Server.MapPath(objProductImage.s_AppLargeImage));
                        //    }
                        //    if (System.IO.File.Exists(Server.MapPath(objProductImage.s_AppNormalImage)))
                        //    {
                        //        System.IO.File.Delete(Server.MapPath(objProductImage.s_AppNormalImage));
                        //    }
                        //    if (System.IO.File.Exists(Server.MapPath(objProductImage.s_AppSmallImage)))
                        //    {
                        //        System.IO.File.Delete(Server.MapPath(objProductImage.s_AppSmallImage));
                        //    }
                        //    if (System.IO.File.Exists(Server.MapPath(objProductImage.s_AppThumbImage)))
                        //    {
                        //        System.IO.File.Delete(Server.MapPath(objProductImage.s_AppLargeImage));
                        //    }
                        //    objProductImage.MoveNext();
                        //}
                        objProductImage.DeleteAll();
                        objProductImage.Save();
                    }
                    objProductImage = null;


                    objProductColor.MoveNext();
                }
                objProductColor.DeleteAll();
                objProductColor.Save();
            }
            objProductColor = null;

            string StrFolder = "Uploads/Product/" + objProduct.s_AppProductID + "/";

            if (System.IO.Directory.Exists(Server.MapPath("~/admin/" + StrFolder)))
            {
                System.IO.Directory.Delete(Server.MapPath("~/admin/" + StrFolder), true);
            }

            objProduct.MarkAsDeleted();
            objProduct.Save();
        }

        retval     = true;
        objProduct = null;
        return(retval);
    }
コード例 #2
0
    public Boolean SaveLeadData()
    {
        DataTable objDataTable = new DataTable();

        if (Session[appFunctions.Session.LeadDataTable.ToString()] != null)
        {
            objDataTable = (DataTable)Session[appFunctions.Session.LeadDataTable.ToString()];
        }
        if (objDataTable.Rows.Count <= 0)
        {
            DInfo.ShowMessage("Some Error Occure Try again!.", Enums.MessageType.Error);
            return(false);
        }


        objCommon = new clsCommon();
        foreach (DataRow row in objDataTable.Rows)
        {
            tblProduct objProduct = new tblProduct();
            objProduct.Where.AppProductName.Value = row[Enums.Enums_ProductHeader.Product_Name.ToString().Replace("_", " ").Trim().ToLower()].ToString();
            objProduct.Query.Load();
            if (objProduct.RowCount <= 0)
            {
                objProduct.AddNew();
            }
            objProduct.s_AppProductName = row[Enums.Enums_ProductHeader.Product_Name.ToString().Replace("_", " ").Trim().ToLower()].ToString();
            objProduct.s_AppProductCode = row[Enums.Enums_ProductHeader.Product_Code.ToString().Replace("_", " ").Trim().ToLower()].ToString();
            objProduct.s_AppDescription = row[Enums.Enums_ProductHeader.Description.ToString().Replace("_", " ").Trim().ToLower()].ToString();
            //objProduct.s_AppProductTag = row[Enums.Enums_ProductHeader.Description.ToString().Replace("_", " ").Trim().ToLower()].ToString();
            objProduct.s_AppMetaKeyWord     = row[Enums.Enums_ProductHeader.Meta_KeyWord.ToString().Replace("_", " ").Trim().ToLower()].ToString();
            objProduct.s_AppMetaDescription = row[Enums.Enums_ProductHeader.Meta_Description.ToString().Replace("_", " ").Trim().ToLower()].ToString();
            objProduct.AppIsFeatured        = false;
            objProduct.AppIsNewArrival      = false;
            objProduct.AppIsBestSeller      = false;
            objProduct.AppIsColor           = true;
            objProduct.AppIsSize            = true;
            objProduct.Save();

            //Color Add or Modify

            string          strColorId      = GetColorId(row[Enums.Enums_ProductHeader.Color_Name.ToString().Replace("_", " ").Trim().ToLower()].ToString());
            tblProductColor objProductColor = new tblProductColor();
            objProductColor.Where.AppProductID.Value = objProduct.s_AppProductID;
            objProductColor.Where.AppColorID.Value   = strColorId;
            objProductColor.Query.Load();
            if (objProductColor.RowCount <= 0)
            {
                objProductColor.AddNew();
                objProductColor.AppDisplayOrder = objCommon.GetNextDisplayOrder("tblProductColor", tblProductColor.ColumnNames.AppDisplayOrder, tblProductColor.ColumnNames.AppProductID + "=" + objProduct.s_AppProductID);
            }
            objProductColor.s_AppColorID   = strColorId;
            objProductColor.s_AppProductID = objProduct.s_AppProductID;


            if (objProductColor.AppDisplayOrder == 1)
            {
                objProductColor.AppIsDefault = true;
            }
            else
            {
                objProductColor.AppIsDefault = false;
            }
            objProductColor.AppIsActive = true;

            objProductColor.Save();


            //Size Add or Modify
            string strSizeId = GetSizeId(row[Enums.Enums_ProductHeader.Size.ToString().Replace("_", " ").Trim().ToLower()].ToString());

            tblProductDetail objProductDetail = new tblProductDetail();
            objProductDetail.Where.AppProductColorID.Value = objProductColor.s_AppProductColorID;
            objProductDetail.Where.AppSizeID.Value         = strSizeId;
            objProductDetail.Query.Load();
            if (objProductDetail.RowCount <= 0)
            {
                objProductDetail.AddNew();
            }
            objProductDetail.s_AppProductColorID = objProductColor.s_AppProductColorID;
            //objProductDetail.s_AppSellerPrice = row[Enums.Enums_ProductHeader.Seller_Price.ToString().Replace("_", " ").Trim().ToLower()].ToString();
            objProductDetail.s_AppMRP      = row[Enums.Enums_ProductHeader.MRP.ToString().Replace("_", " ").Trim().ToLower()].ToString();
            objProductDetail.s_AppPrice    = row[Enums.Enums_ProductHeader.Price.ToString().Replace("_", " ").Trim().ToLower()].ToString();
            objProductDetail.s_AppQuantity = row[Enums.Enums_ProductHeader.Quantity.ToString().Replace("_", " ").Trim().ToLower()].ToString();
            objProductDetail.AppSKUNo      = row[Enums.Enums_ProductHeader.SKU_No.ToString().Replace("_", " ").Trim().ToLower()].ToString();
            objProductDetail.s_AppSizeID   = strSizeId;
            objProductDetail.AppIsDefault  = false;
            tblProductDetail objTempmg = new tblProductDetail();
            objTempmg.Where.AppProductColorID.Value = strSizeId;
            objTempmg.Query.Load();
            if (objTempmg.RowCount <= 0)
            {
                objProductDetail.AppIsDefault = true;
            }
            objTempmg = null;

            objProductDetail.Save();

            objProductDetail = null;


            string StrFolder  = "Uploads/Product/" + objProduct.s_AppProductID + "/";
            string strImgName = objProduct.s_AppProductName.Trim().Replace(" ", "_") + "_" + row[Enums.Enums_ProductHeader.Color_Name.ToString().Replace("_", " ").Trim().ToLower()].ToString().Replace(" ", "_");

            if (!(System.IO.Directory.Exists(Server.MapPath("~/admin/" + StrFolder))))
            {
                System.IO.Directory.CreateDirectory(Server.MapPath("~/admin/" + StrFolder));
            }
            for (int i = 1; i <= 4; i++)
            {
                string ImgPath = row[Enums.Enums_ProductHeader.Image.ToString().Replace("_", " ").Trim().ToLower() + " " + i.ToString()].ToString();

                try
                {
                    System.Drawing.Bitmap upBmp = (System.Drawing.Bitmap)System.Drawing.Image.FromFile(ImgPath);

                    if (row[Enums.Enums_ProductHeader.Image.ToString().Replace("_", " ").Trim().ToLower() + " " + i.ToString()].ToString() != "")
                    {
                        tblProductImage objProductImg = new tblProductImage();
                        objProductImg.AddNew();
                        objProductImg.s_AppProductColorID = objProductColor.s_AppProductColorID;
                        objProductImg.AppDisplayOrder     = objCommon.GetNextDisplayOrder("tblProductImage", tblProductImage.ColumnNames.AppDisplayOrder, tblProductImage.ColumnNames.AppProductColorID + "=" + objProductColor.s_AppProductColorID);
                        string strError = "";
                        string Time     = Convert.ToString(DateTime.Now.Month) + Convert.ToString(DateTime.Now.Day) + Convert.ToString(DateTime.Now.Year) + Convert.ToString(DateTime.Now.Hour) + Convert.ToString(DateTime.Now.Minute) + Convert.ToString(DateTime.Now.Second) + Convert.ToString(DateTime.Now.Millisecond);
                        string strPath  = objCommon.ResizeDirectImagesFile(ImgPath, strImgName + "_" + Time + "_Thumb", 0, ref strError, StrFolder, 0, 91);
                        if (strError == "")
                        {
                            objProductImg.s_AppThumbImage = strPath;
                        }
                        strError = "";
                        strPath  = objCommon.ResizeDirectImagesFile(ImgPath, strImgName + "_" + Time + "_Normal", 0, ref strError, StrFolder, 0, 300);
                        if (strError == "")
                        {
                            objProductImg.s_AppNormalImage = strPath;
                        }
                        strError = "";
                        strPath  = objCommon.ResizeDirectImagesFile(ImgPath, strImgName + "_" + Time + "_Large", 0, ref strError, StrFolder, 0, 900);
                        if (strError == "")
                        {
                            objProductImg.s_AppLargeImage = strPath;
                        }
                        strError = "";
                        strPath  = objCommon.ResizeDirectImagesFile(ImgPath, strImgName + "_" + Time + "_Small", 0, ref strError, StrFolder, 0, 210);
                        if (strError == "")
                        {
                            objProductImg.s_AppSmallImage = strPath;
                        }
                        objProductImg.AppIsActive  = true;
                        objProductImg.AppIsDefault = false;

                        if (objProductImg.AppDisplayOrder == 1)
                        {
                            objProductImg.AppIsActive  = true;
                            objProductImg.AppIsDefault = true;
                        }
                        objProductImg.Save();
                        objProductImg = null;
                    }
                }
                catch (Exception ex)
                {
                }
            }
            objProductColor = null;

            objProduct = null;
            //objlead.s_appcampaignid = row["appcampaignid"].tostring();
        }
        objCommon    = null;
        objDataTable = null;
        return(true);
    }