Exemple #1
0
    private DAProduct CreateObjectFromPage()
    {
        // check
        DAProduct daProduct = new DAProduct();

        daProduct.USP_Product_GetFullID(this.KeyID);
        //
        daProduct.fProductName   = fProductName.Value.Trim();
        daProduct.fProductNosign = Utils.convertToUnSign2(fProductName.Value);
        daProduct.fDescription   = fDescription.Content.Trim();
        daProduct.fProductCode   = fProductCode.Value.Trim();
        daProduct.fUnitName      = fUnitName.Value.Trim();
        daProduct.fProducerID    = Convert.ToInt32(fProducerID.Value.Trim());
        daProduct.fPrice         = Convert.ToInt32(fPrice.Value.Trim());
        daProduct.fSalePrice     = Convert.ToInt32(fSalePrice.Value.Trim());
        daProduct.fSchSalePrice  = Convert.ToInt32(fSchSalePrice.Value.Trim());
        daProduct.fScheSaleFrom  = Convert.ToDateTime(fScheSaleFrom.SelectedDate);
        daProduct.fScheSaleTo    = Convert.ToDateTime(fScheSaleTo.SelectedDate);
        daProduct.fVATID         = Convert.ToInt32(fVATID.Value.Trim());
        //daProduct.fThumbLink = fThumbLink.ImageUrl;
        //daProduct.fImgLink1 = fImage1.;
        //daProduct.fImgLink2 = fImage2.ImageUrl;
        //daProduct.fImgLink3 = fImage3.ImageUrl;
        //daProduct.fImgLink4 = fImage4.ImageUrl;
        //daProduct.fImgLink5 = fImage5.ImageUrl;


        //uploadImages(ref daProduct);

        // Image 1
        HttpPostedFile fileImg1 = inputFileImg1.PostedFile;

        if (fileImg1 != null && fileImg1.ContentLength > 0)
        {
            //Delete old file
            Utils.DeleteFile(fImgLink1.ImageUrl, Server);
            daProduct.fImgLink1 = Utils.UploadImage(fileImg1, Server, "~/Media/Product");
        }
        else
        {
            daProduct.fImgLink1 = fImgLink1.ImageUrl.Replace("~", "");
        }
        fImgLink1.ImageUrl = "~" + daProduct.fImgLink1;

        // End


        // Image 2
        HttpPostedFile fileImg2 = inputFileImg2.PostedFile;

        if (fileImg2 != null && fileImg2.ContentLength > 0)
        {
            //Delete old file
            Utils.DeleteFile(fImgLink2.ImageUrl, Server);
            daProduct.fImgLink2 = Utils.UploadImage(fileImg2, Server, "~/Media/Product");
        }
        else
        {
            daProduct.fImgLink2 = fImgLink2.ImageUrl.Replace("~", "");
        }
        fImgLink2.ImageUrl = "~" + daProduct.fImgLink2;
        // End


        // Image 3
        HttpPostedFile fileImg3 = inputFileImg3.PostedFile;

        if (fileImg3 != null && fileImg3.ContentLength > 0)
        {
            //Delete old file
            Utils.DeleteFile(fImgLink3.ImageUrl, Server);
            daProduct.fImgLink3 = Utils.UploadImage(fileImg3, Server, "~/Media/Product");
        }
        else
        {
            daProduct.fImgLink3 = fImgLink3.ImageUrl.Replace("~", "");
        }
        fImgLink3.ImageUrl = "~" + daProduct.fImgLink3;
        // End

        //End

        // Image 4
        HttpPostedFile fileImg4 = inputFileImg4.PostedFile;

        if (fileImg4 != null && fileImg4.ContentLength > 0)
        {
            //Delete old file
            Utils.DeleteFile(fImgLink4.ImageUrl, Server);
            daProduct.fImgLink4 = Utils.UploadImage(fileImg4, Server, "~/Media/Product");
        }
        else
        {
            daProduct.fImgLink4 = fImgLink4.ImageUrl.Replace("~", "");
        }
        fImgLink4.ImageUrl = "~" + daProduct.fImgLink4;
        // End


        // Image 5
        // Image 3
        HttpPostedFile fileImg5 = inputFileImg5.PostedFile;

        if (fileImg5 != null && fileImg5.ContentLength > 0)
        {
            //Delete old file
            Utils.DeleteFile(fImgLink5.ImageUrl, Server);
            daProduct.fImgLink5 = Utils.UploadImage(fileImg5, Server, "~/Media/Product");
        }
        else
        {
            daProduct.fImgLink5 = fImgLink5.ImageUrl.Replace("~", "");
        }
        fImgLink5.ImageUrl = "~" + daProduct.fImgLink5;
        // End
        // End


        daProduct.fIsManagerQuantity = fIsManagerQuantity.Checked;
        daProduct.fQuantity          = Convert.ToInt32(fQuantity.Value.Trim());
        daProduct.fNumSaled          = Convert.ToInt32(fNumSaled.Value.Trim());
        daProduct.fRewriteURL        = fRewriteURL.Value.Trim();
        daProduct.fPageTitle         = fPageTitle.Value.Trim();
        daProduct.fMetaTitle         = fMetaTitle.Value.Trim();
        daProduct.fMetaDescription   = fMetaDescription.Value.Trim();
        daProduct.fMetaKeywords      = fMetaKeywords.Value.Trim();
        daProduct.fTags                = fTags.Value.Trim();
        daProduct.fDesShort            = fDesShort.Value.Trim();
        daProduct.fDesBeforPrice       = fDesBeforPrice.Value.Trim();
        daProduct.fDesAfterPrice       = fDesAfterPrice.Value.Trim();
        daProduct.fIsNewProduct        = fIsNewProduct.Checked;
        daProduct.fIsHot               = fIsHot.Checked;
        daProduct.fIsShow              = fIsShow.Checked;
        daProduct.fIsHiddenWhenOutoff  = fIsHiddenWhenOutoff.Checked;
        daProduct.fIsShowYouSaving     = fIsShowYouSaving.Checked;
        daProduct.fBuyButtonText       = fBuyButtonText.Value.Trim();
        daProduct.fShowInProductTyleID = Convert.ToInt32(fShowInProductTyleID.Value.Trim());
        daProduct.fMinOrder            = Convert.ToInt32(fMinOrder.Value.Trim());
        daProduct.fMaxForWarrning      = Convert.ToInt32(fMaxForWarrning.Value.Trim());
        daProduct.fBonusPoint          = Convert.ToInt32(fBonusPoint.Value.Trim());
        daProduct.fIsAllowComment      = fIsAllowComment.Checked;
        daProduct.fPos      = Convert.ToInt32(fPos.Value.Trim());
        daProduct.fOperator = MySession.UserName;

        //

        return(daProduct);
    }
Exemple #2
0
    override protected Boolean LoadData()
    {
        try
        {
            LoadCategory();

            // Load Data For Page.
            DAProduct daProduct = new DAProduct();
            daProduct.USP_Product_GetFullID(this.KeyID);
            //
            fProductName.Value         = daProduct.fProductName.ToString();
            fDescription.Content       = daProduct.fDescription.ToString();
            fProductCode.Value         = daProduct.fProductCode.ToString();
            fUnitName.Value            = daProduct.fUnitName.ToString();
            fProducerID.Value          = daProduct.fProducerID.ToString();
            fPrice.Value               = daProduct.fPrice.ToString();
            fSalePrice.Value           = daProduct.fSalePrice.ToString();
            fSchSalePrice.Value        = daProduct.fSchSalePrice.ToString();
            fScheSaleFrom.SelectedDate = daProduct.fScheSaleFrom;
            fScheSaleTo.SelectedDate   = daProduct.fScheSaleTo;
            fVATID.Value               = daProduct.fVATID.ToString();

            fImgLink1.ImageUrl = "~" + daProduct.fImgLink1;
            fImgLink2.ImageUrl = "~" + daProduct.fImgLink2;
            fImgLink3.ImageUrl = "~" + daProduct.fImgLink3;
            fImgLink4.ImageUrl = "~" + daProduct.fImgLink4;
            fImgLink5.ImageUrl = "~" + daProduct.fImgLink5;

            //fImage1.Src = daProduct.fImgLink1 == String.Empty ? String.Empty : "~" + daProduct.fImgLink1;
            //fImage2.Src = daProduct.fImgLink2 == String.Empty ? String.Empty : "~" + daProduct.fImgLink2;
            //fImage3.Src = daProduct.fImgLink3 == String.Empty ? String.Empty : "~" + daProduct.fImgLink3;
            //fImage4.Src = daProduct.fImgLink4 == String.Empty ? String.Empty : "~" + daProduct.fImgLink4;
            //fImage5.Src = daProduct.fImgLink5 == String.Empty ? String.Empty : "~" + daProduct.fImgLink5;

            fIsManagerQuantity.Checked = daProduct.fIsManagerQuantity;
            fQuantity.Value            = daProduct.fQuantity.ToString();
            fNumSaled.Value            = daProduct.fNumSaled.ToString();
            fRewriteURL.Value          = daProduct.fRewriteURL.ToString();
            fPageTitle.Value           = daProduct.fPageTitle.ToString();
            fMetaTitle.Value           = daProduct.fMetaTitle.ToString();
            fMetaDescription.Value     = daProduct.fMetaDescription.ToString();
            fMetaKeywords.Value        = daProduct.fMetaKeywords.ToString();
            fTags.Value                 = daProduct.fTags.ToString();
            fDesShort.Value             = daProduct.fDesShort.ToString();
            fDesBeforPrice.Value        = daProduct.fDesBeforPrice.ToString();
            fDesAfterPrice.Value        = daProduct.fDesAfterPrice.ToString();
            fIsNewProduct.Checked       = daProduct.fIsNewProduct;
            fIsHot.Checked              = daProduct.fIsHot;
            fIsShow.Checked             = daProduct.fIsShow;
            fIsHiddenWhenOutoff.Checked = daProduct.fIsHiddenWhenOutoff;
            fIsShowYouSaving.Checked    = daProduct.fIsShowYouSaving;
            fBuyButtonText.Value        = daProduct.fBuyButtonText.ToString();
            fShowInProductTyleID.Value  = daProduct.fShowInProductTyleID.ToString();
            fMinOrder.Value             = daProduct.fMinOrder.ToString();
            fMaxForWarrning.Value       = daProduct.fMaxForWarrning.ToString();
            fBonusPoint.Value           = daProduct.fBonusPoint.ToString();
            fIsAllowComment.Checked     = daProduct.fIsAllowComment;
            fPos.Value            = daProduct.fPos.ToString();
            fSysDate.SelectedDate = daProduct.fSysDate;

            //

            // Khi cần enabled cột nào
            //if (this.KeyID > 0)
            //{
            //    if (mode != Act.Clone)
            //        fUserName.Enabled = false;
            //    else
            //        fUserName.Text = "";
            //}
        }
        catch (Exception e)
        {
            ShowErrorMes("Lỗi hệ thống: " + e.ToString());
            return(false);
        }

        return(true);
    }