protected void btnSave_Click(object sender, EventArgs e)
    {
        ProductFile obj = new ProductFile();
        obj.Data = this.SetData();

        DataTable objtable = new DataTable();
        obj.SearchAll();
        objtable = obj.SearchAll();
        string strFileName = ConvertData.ConvertToString(txtFileName.Text.Trim());

        bool bcheck = true;

        int nResult = 0;

        string sAction = Request.QueryString[Constants.ACTION];
        switch (sAction)
        {
            case Constants.ACTION_ADD:
                nResult = obj.Insert();
                if (iptProductFile.Value != "")
                {
                    if (nResult > 0)
                    {
                        string sURL = Constants.ROOT + Pages.BackEnds.ADMIN + "?" + Constants.PAGE + "=" + Pages.BackEnds.STR_PRODUCTFILE + "&" + Constants.MESS_ID + "=" + Constants.MESSAGE_INSERT;
                        Response.Redirect(sURL);
                    }
                    else
                    {
                        MessageBoxss.Show(MessagesAlert.UPDATE_UNSUCCESSFUL);
                    }
                }
                else
                {
                    MessageBoxss.Show("File đính kèm chưa được thêm .");
                }

                break;
            case Constants.ACTION_EDIT:
                int nID = ConvertData.ConvertToInt(Request.QueryString[Constants.ACTION_ID]);
                nResult = obj.Update(nID);
                if (nResult > 0)
                {
                    string sURL = Constants.ROOT + Pages.BackEnds.ADMIN + "?" + Constants.PAGE + "=" + Pages.BackEnds.STR_PRODUCTFILE + "&" + Constants.MESS_ID + "=" + Constants.MESSAGE_UPDATE;
                    Response.Redirect(sURL);
                    //MessageBoxss.Show(MessagesAlert.UPDATE_SUCCESSFUL);
                }
                else
                    MessageBoxss.Show(MessagesAlert.UPDATE_UNSUCCESSFUL);
                break;
        }
    }
    protected void RpProductCategory_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        string strCommand = e.CommandName;
        int nID = ConvertData.ConvertToInt(e.CommandArgument);
        ProductFile objProductFile = new ProductFile();
        switch (strCommand)
        {
            case "Delete":
                int nDelete = objProductFile.DeleteById(nID);
                BindData();
                break;

            case "Edit":
                string sEdit = Constants.ROOT + Pages.BackEnds.ADMIN + "?" + Constants.PAGE + "=" + Pages.BackEnds.STR_PRODUCTFILE_ADD + "&" + Constants.ACTION + "=" + Constants.ACTION_EDIT + "&" + Constants.ACTION_ID + "=" + nID;
                Response.Redirect(sEdit);
                break;
        }
    }
Пример #3
0
    private void SetProductFileToRepeater(int ProductID)
    {
        if (ProductID > 0)
        {
            int nPageCount = 0;
            DataTable dtbSetColor = new DataTable();
            ProductFile objSetColor = new ProductFile();
            dtbSetColor = objSetColor.SearchByIDProduct(ProductID, 1, 10000, ref nPageCount);
            int nCount = dtbSetColor.Rows.Count;

            int nCountColor = rptProducFile.Items.Count;
            for (int i = 1; i <= nCountColor; i++)
            {
                HtmlInputCheckBox chk = (HtmlInputCheckBox)rptProducFile.Items[i - 1].FindControl("chkFile");
                Label lblID = (Label)rptProducFile.Items[i - 1].FindControl("lblProductFileID");
                for (int j = 1; j <= nCount; j++)
                {
                    int nColorID = (int)dtbSetColor.Rows[j - 1][1];
                    if (nColorID == ConvertData.ConvertToInt(lblID.Text))
                    {
                        chk.Checked = true;
                    }
                }
            }
        }
    }
Пример #4
0
    private void BindProductFile()
    {
        DataTable dtbColor = new DataTable();
        ProductFile objColor = new ProductFile();
        dtbColor = objColor.SearchAll();

        rptProducFile.DataSource = dtbColor;
        rptProducFile.DataBind();
    }
    private void InitData()
    {
        int nID = ConvertData.ConvertToInt(Request.QueryString["pid"]);

        try
        {

            Products obj = new Products();
            obj.LoadById(nID);
            lblProductName.Text = obj.Data.ProductName;
            lblPrice.Text = ConvertData.ConvertToString(Support.FormatCurrency(obj.Data.Price)) + " " + "vn₫";
            lblContent.Text = obj.Data.MainContent;

            int nCat = obj.Data.ProductCategoryID;

            lblIDAdd.Text = ConvertData.ConvertToString(nID);
            lblNameAdd.Text = obj.Data.ProductName;
            lblPriceAdd.Text = ConvertData.ConvertToString(obj.Data.Price);

            DataTable dtb = new DataTable();
            dtb = obj.Search_byItemID(0, nID, "", 0, 1000000000, nCat, 1, 1, 5, ref nPageCount);
            rptRelated.DataSource = dtb;
            rptRelated.DataBind();

            DataTable dtbFile = new DataTable();
            ProductFile objProductFile = new ProductFile();
            dtbFile = objProductFile.SearchByIDProduct(nID, 1, 10, ref nPageCount);
            rptProductFile.DataSource = dtbFile;
            rptProductFile.DataBind();

            if (dtbFile.Rows.Count == 0)
            {
                lblFile.Visible = false;
                div_file.Style.Add("display", "none");
            }

            //StaticPages objStaticPage = new StaticPages();
            //objStaticPage.LoadById(13);
            //ltrContentThuTuc.Text = objStaticPage.Data.PageContent;

        }
        catch { Response.Redirect("Default.aspx"); }
    }
    private void BindDataWhenEdit()
    {
        string sAction = ConvertData.ConvertToString(Request.QueryString[Constants.ACTION]);
        try
        {
            if (sAction == Constants.ACTION_EDIT)
            {
                int nID = ConvertData.ConvertToInt(Request.QueryString[Constants.ACTION_ID]);
                if (nID > 0)
                {
                    ProductFile obj = new ProductFile();
                    obj.LoadById(nID);

                    txtFileName.Text = ConvertData.ConvertToString(obj.Data.FileName);

                    if (obj.Data.Url != "")
                    {
                        div_file.Visible = true;
                        lnkFileName.Text = ConvertData.ConvertToString(obj.Data.Url);
                    }
                    //lnkFileName.NavigateUrl = ConvertData.ConvertToString(obj.Data.Url);

                }
            }
        }
        catch
        {
            string sLink = Constants.ROOT + Pages.BackEnds.ADMIN + "?" + Constants.PAGE + "=" + Pages.BackEnds.STR_PRODUCTFILE;
            Response.Redirect(sLink);
        }
    }
    private eProductFile SetData()
    {
        eProductFile eProductEntity = this.ProductFileEntity();
        ProductFile objProductFile = new ProductFile();

        objProductFile.Data.FileName = ConvertData.ConvertToString(txtFileName.Text.Trim());

        if (iptProductFile.Value != "")
        {
            Support.DeleteFile("productfile", eProductEntity.Url);
            objProductFile.Data.Url = Support.UploadFile(iptProductFile, "productfile");
        }
        if (iptProductFile.Value == "")
        {
            if (eProductEntity.Url != null && eProductEntity.Url.Length > 0)
            { objProductFile.Data.Url = eProductEntity.Url; }
            else
            {

                objProductFile.Data.Url = "";

            }
        }

        return objProductFile.Data;
    }
 private eProductFile ProductFileEntity()
 {
     eProductFile entityProductFile = new eProductFile();
     int nItemID = ConvertData.ConvertToInt(Request.QueryString[Constants.ACTION_ID]);
     string sQueery = ConvertData.ConvertToString(Request.QueryString[Constants.ACTION]);
     if (nItemID > 0 && sQueery == Constants.ACTION_EDIT)
     {
         ProductFile obj = new ProductFile();
         obj.LoadById(nItemID);
         entityProductFile = obj.Data;
     }
     return entityProductFile;
 }
 private void BindData()
 {
     DataTable objTable = new DataTable();
     ProductFile obj = new ProductFile();
     objTable = obj.SearchAll();
     RpProductCategory.DataSource = objTable;
     RpProductCategory.DataBind();
 }
Пример #10
0
    protected void rptProducts_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Products objProducts = new Products();
        DataTable dtbFile = new DataTable();
        ProductFile objProductFile = new ProductFile();
        int nPageCount = 0;
        if ((e.Item.ItemType != ListItemType.Header) && (e.Item.ItemType != ListItemType.Footer))
        {
            Label lnkFileName = (Label)e.Item.FindControl("lblFileName");
            Repeater rptFile = (Repeater)e.Item.FindControl("rptFile");
            int nID = ConvertData.ConvertToInt(DataBinder.Eval(e.Item.DataItem, "ID"));
            objProducts.LoadById(nID);
            lnkFileName.Text = objProducts.Data.ProductName;

            dtbFile = objProductFile.SearchByIDProduct(nID, 1, 10, ref nPageCount);

            if(dtbFile.Rows.Count==0){
                lnkFileName.Visible = false;
            }
            rptFile.DataSource = dtbFile;
            rptFile.DataBind();
        }
    }