예제 #1
0
    protected void Saved_Product(object sender, EventArgs e)
    {
        books bookcontent = new books();

        if (ProductId.Value != null && ProductId.Value != string.Empty)
        {
            alamaat_product item = bookcontent.GetproductById(new Guid(ProductId.Value.ToString()));
            if (null != item)
            {
                bookinterface newitem = new bookinterface();
                newitem.ID            = item.id;
                newitem.Name          = tbname.Text;
                newitem.Category      = new Guid(ComboCategory.SelectedValue.ToString());
                newitem.OriginalPrice = Convert.ToDecimal(tbprice.Text);
                newitem.Discount      = Convert.ToInt16(tbdiscount.Text);
                newitem.Price         = Convert.ToDecimal(tbSaleprice.Text);
                newitem.Details       = tbdetails.Text;
                newitem.Imageid       = new Guid(ImgId.Value.ToString());

                if (bookcontent.UpdateItem(newitem))
                {
                    lbloutput.Text = "Item Updated Successfully.";
                    clear();
                }
            }
        }
        else
        {
            bookinterface newitem = new bookinterface();
            newitem.Name          = tbname.Text;
            newitem.Category      = new Guid(ComboCategory.SelectedValue.ToString());
            newitem.OriginalPrice = Convert.ToDecimal(tbprice.Text);
            newitem.Discount      = Convert.ToInt16(tbdiscount.Text);
            newitem.Price         = Convert.ToDecimal(tbSaleprice.Text);
            newitem.Details       = tbdetails.Text;
            newitem.Imageid       = new Guid(ImgId.Value.ToString());


            if (bookcontent.InsertItem(newitem))
            {
                lbloutput.Text = "Item Saved Successfully.";
                clear();
            }
        }
    }
예제 #2
0
    protected void EditClick(object sender, CommandEventArgs e)
    {
        lbloutput.Text = "";
        Guid            id          = new Guid((e.CommandArgument).ToString());
        books           bookcontent = new books();
        alamaat_product item        = bookcontent.GetproductById(id);

        if (null != item)
        {
            ProductId.Value = id.ToString();
            tbname.Text     = item.productname;
            if (item.originalprice != null)
            {
                tbprice.Text = item.originalprice.ToString();
            }
            else
            {
                tbprice.Text = item.price.ToString();
            }
            ComboCategory.SelectedValue = item.category.ToString();
            tbdetails.Text = item.details;
            if (item.fileid != null)
            {
                ImgId.Value  = item.fileid.ToString();
                Img.ImageUrl = "~/ShowImage2.ashx?id=" + item.fileid;
                Thumb ImageThumb         = new Thumb();
                List <ProductThumb> list = ImageThumb.GetListbyid(ImgId.Value);
                DataList1.DataSource = list;
                DataList1.DataBind();
            }
            if (item.discount != null)
            {
                tbdiscount.Text = item.discount.ToString();
            }
            else
            {
                tbdiscount.Text = "0";
            }


            tbSaleprice.Text = item.price.ToString();
            tbname.Focus();
        }
    }