Exemplo n.º 1
0
        protected void grdProductMaster_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Delete_Product")
            {
                int         rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                GridViewRow grid     = grdProductMaster.Rows[rowIndex];
                int         id       = Convert.ToInt32(((Label)grid.FindControl("lblID")).Text);

                obj1 = new ProductMasterDataManager();
                obj1.DeleteProductDetail(id);
                Clear();
                bind();
                msgbox("Product Deleted successfully!!!");
            }
            if (e.CommandName == "Change_ProductType")
            {
                int         rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                GridViewRow grid     = grdProductMaster.Rows[rowIndex];
                int         id       = Convert.ToInt32(((Label)grid.FindControl("lblID")).Text);
                int         type     = ((Label)grid.FindControl("lblSample")).Text.ToUpper().Equals("TRUE") ? 0 : 1;
                obj1 = new ProductMasterDataManager();
                obj1.UpdateProductType(id, type);
                Clear();
                bind();
                msgbox("Product Type updated successfully!!!");
            }
        }
Exemplo n.º 2
0
        protected void btnAddProduct_Click(object sender, EventArgs e)
        {
            DateTime dt, dt1;

            obj                 = new ProductMaster();
            obj.Name            = txtName.Text;
            obj.Description     = txtDescription.Text;
            obj.SubjectID       = Convert.ToInt16(ddlSubject.SelectedValue);
            obj.DiscountID      = Convert.ToInt16(ddlDiscount.SelectedValue);
            obj.YearwisePaperID = Convert.ToInt16(ddlPaper.SelectedValue);
            obj.TopicID         = Convert.ToInt16(ddlTopic.SelectedValue);
            obj.Price           = Convert.ToDouble("0" + txtPrice.Text);
            obj.BaseCurrency    = ddlCurrency.SelectedValue;
            obj.ProductType     = Convert.ToInt16('0' + ddlProductType.SelectedValue);
            obj.IsSample        = chkSample.Checked;
            if (DateTime.TryParseExact(txtValidFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt))
            {
                obj.ValidFrom = dt;
            }
            else
            {
                msgbox("Invalid ValidFrom Date");
                return;
            }
            if (DateTime.TryParseExact(txtValidTo.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt1))
            {
                obj.ValidUpto = dt1;
            }
            else
            {
                msgbox("Invalid ValidTo Date");
                return;
            }

            if (dt.Date > dt1.Date)
            {
                msgbox("ValidFrom date should be less than ValidTo date");
                return;
            }
            //obj.IsVisible = chkVisible.Checked;
            obj.CreatedBy = 1;
            obj.UpdatedBy = 1;
            obj.ProductID = Convert.ToInt16(lblProductID.Text);

            if (lblProductID.Text.Equals("-1"))
            {
                obj1 = new ProductMasterDataManager();
                obj1.AddProductDetail(obj);
                msgbox("Product Added successfully!!!");
            }
            else
            {
                obj1 = new ProductMasterDataManager();
                obj1.UpdateProductDetail(obj);
                msgbox("Product updated successfully!!!");
            }
            Clear();
            bind();
        }
Exemplo n.º 3
0
 private void bind()
 {
     obj1 = new ProductMasterDataManager();
     grdProductMaster.DataSource = obj1.GetProductList();
     grdProductMaster.DataBind();
 }