示例#1
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);
    }