示例#1
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        GridViewRow row = (GridViewRow)GridView1.Rows[Convert.ToInt32(e.CommandArgument)];
        Label lblSNO = (Label)row.FindControl("lblSNO");

        if (e.CommandName == "Edit")
        {

            PageStatus = RowStatusType.EDIT;
            int sno = Convert.ToInt32(lblSNO.Text);
            if (listProductGrid.Where(p => p.SNO == sno).First() != null)
            {

                PRODUCTGRID obj = new PRODUCTGRID();
                obj = listProductGrid.Where(p => p.SNO == sno).First();

                bindmobilepart(obj.Mobile_Company_ID);
                ddlCompany.SelectedValue = obj.Mobile_Company_ID;
                ddlMobilePart.SelectedValue = obj.Mobile_Part_ID;
                txtQuantity.Text = Convert.ToString(obj.QUANTITY);
                rbtnPartPending.SelectedValue = Convert.ToString(obj.Pending);
                RowNO = obj.SNO;
                btnAdd.Text = "Edit";

            }
        }

        if (e.CommandName == "Delete")
        {
            int sno = Convert.ToInt32(lblSNO.Text);
            if (listProductGrid.Where(p => p.SNO == sno).First() != null)
            {
                PRODUCTGRID obj = new PRODUCTGRID();
                obj = listProductGrid.Where(p => p.SNO == sno).First();
                listProductGrid.Remove(obj);
                GridView1.DataSource = listProductGrid;
                GridView1.DataBind();
            }

        }
    }
示例#2
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {

            if (this.QUANTITY < 0 && rbtnPartPending.SelectedValue == "0")
            {
                string script = "alert('" + "Quantity left cannot be negative" + "');";

                ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", script, true);

            }

            else
            {
                if (PageStatus == RowStatusType.NEW)
                {
                    List<PRODUCTGRID> table = listProductGrid;

                    PRODUCTGRID objproduct = new PRODUCTGRID();
                    objproduct.SNO = listProductGrid.Count() + 1;
                    objproduct.Mobile_Company = ddlCompany.SelectedItem.ToString();
                    objproduct.Mobile_Company_ID = ddlCompany.SelectedValue.ToString();
                    objproduct.Mobile_Part = ddlMobilePart.SelectedItem.ToString();
                    objproduct.Mobile_Part_ID = ddlMobilePart.SelectedValue.ToString();

                    objproduct.QUANTITY = Convert.ToDecimal(txtQuantity.Text.Trim());
                    objproduct.Pending = Convert.ToInt32(rbtnPartPending.SelectedValue);
                    table.Add(objproduct);
                    GridView1.DataSource = table;

                    GridView1.DataBind();
                    txtQuantity.Text = string.Empty;
                }
                else
                {
                    PRODUCTGRID objproduct = listProductGrid.Where(p => p.SNO == RowNO).First();
                    objproduct.SNO = listProductGrid.Count() + 1;
                    objproduct.Mobile_Company = ddlCompany.SelectedItem.ToString();
                    objproduct.Mobile_Company_ID = ddlCompany.SelectedValue.ToString();
                    objproduct.Mobile_Part = ddlMobilePart.SelectedItem.ToString();
                    objproduct.Mobile_Part_ID = ddlMobilePart.SelectedValue.ToString();

                    objproduct.QUANTITY = Convert.ToDecimal(txtQuantity.Text.Trim());
                    objproduct.Pending = Convert.ToInt32(rbtnPartPending.SelectedValue);

                    btnAdd.Text = "Add";
                    txtQuantity.Text = string.Empty;
                    GridView1.DataSource = listProductGrid;

                    GridView1.DataBind();
                    PageStatus = RowStatusType.NEW;

                }
            }

        }
    }
示例#3
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        //int index = Convert.ToInt32(e.CommandArgument);
        //int Id = Convert.ToInt32(GridView1.DataKeys[index].Value) - 1;
        //GridViewRow row = (GridViewRow)GridView1.Rows[index];

        GridViewRow row = (GridViewRow)GridView1.Rows[Convert.ToInt32(e.CommandArgument)];
        Label lblSNO = (Label)row.FindControl("lblSNO");

        if (e.CommandName == "Edit")
        {

            PageStatus = RowStatusType.EDIT;
            int sno = Convert.ToInt32(lblSNO.Text);
            if (listProductGrid.Where(p => p.SNO == sno).First() != null)
            {

                PRODUCTGRID obj = new PRODUCTGRID();
                obj = listProductGrid.Where(p => p.SNO == sno).First();
                ddlProduct.SelectedValue = obj.PRODUCT_TYPE_ID;
                ddlSubProduct.SelectedValue = obj.PRODUCT_SUBTYPE_ID;
                txtQuantity.Text = Convert.ToString(obj.QUANTITY);
                txtRate.Text = Convert.ToString(obj.RATE);
                RowNO = obj.SNO;
                btnAdd.Text = "Edit";

            }
        }

        if (e.CommandName == "Delete")
        {
            int sno = Convert.ToInt32(lblSNO.Text);
            if (listProductGrid.Where(p => p.SNO == sno).First() != null)
            {
                PRODUCTGRID obj = new PRODUCTGRID();
                obj = listProductGrid.Where(p => p.SNO == sno).First();
                NetAmount = NetAmount - obj.AMOUNT;
                txtTotAmt.Text = NetAmount.ToString();
                txtAmtwrds.Text = Convert.ToString(Rupees(Convert.ToInt64(NetAmount)));
                listProductGrid.Remove(obj);
                GridView1.DataSource = listProductGrid;
                GridView1.DataBind();
            }

        }
    }
示例#4
0
    public void bindMPartGrid()
    {
        if (conn != null)
        {
            SqlConnection con = new SqlConnection(conn);
            con.Open();
            string command = "select ROW_NUMBER() Over (Order by a.SNO) As SNO,a.Part_Company_ID as Mobile_Company_ID,b.Product_Type as Mobile_Company,a.Part_ID as Mobile_Part_ID,c.Part_Name as Mobile_Part,QUANTITY,Pending,Request_ID from RepairRequest_Progress a   inner join Product b on a.part_company_id=b.SNO inner join Parts_Details c on a.part_id=c.SNO  where Request_ID='" + this.REQUEST_ID + "'";
            SqlCommand cmd = new SqlCommand(command, con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            con.Close();
            List<PRODUCTGRID> table = listProductGrid;

            foreach (DataRow row in ds.Tables[0].Rows)
            {

                PRODUCTGRID objproduct = new PRODUCTGRID();
                objproduct.SNO = listProductGrid.Count() + 1;
                objproduct.Mobile_Company = row["Mobile_Company"].ToString();
                objproduct.Mobile_Company_ID = row["Mobile_Company_ID"].ToString();
                objproduct.Mobile_Part = row["Mobile_Part"].ToString();
                objproduct.Mobile_Part_ID = row["Mobile_Part_ID"].ToString();

                objproduct.QUANTITY = Convert.ToDecimal(row["QUANTITY"].ToString());
                if (!String.IsNullOrEmpty(row["Pending"].ToString()))
                    objproduct.Pending = Convert.ToInt32(row["Pending"].ToString());
                else
                    objproduct.Pending = 1;

                table.Add(objproduct);
            }
            GridView1.DataSource = table;

            GridView1.DataBind();

        }
    }
示例#5
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            if (PageStatus == RowStatusType.NEW)
            {
                List<PRODUCTGRID> table = listProductGrid;

                PRODUCTGRID objproduct = new PRODUCTGRID();
                objproduct.SNO = listProductGrid.Count() + 1;
                objproduct.PRODUCT_TYPE = ddlProduct.SelectedItem.ToString();
                objproduct.PRODUCT_TYPE_ID = ddlProduct.SelectedValue.ToString();
                objproduct.PRODUCT_SUBTYPE = ddlSubProduct.SelectedItem.ToString();
                objproduct.PRODUCT_SUBTYPE_ID = ddlSubProduct.SelectedValue.ToString();
                objproduct.RATE = Convert.ToDecimal(txtRate.Text.Trim());
                objproduct.QUANTITY = Convert.ToDecimal(txtQuantity.Text.Trim());
                objproduct.AMOUNT = (Convert.ToDecimal(txtRate.Text.Trim()) * Convert.ToDecimal(txtQuantity.Text.Trim()));

                NetAmount = NetAmount + objproduct.AMOUNT;

                table.Add(objproduct);
                GridView1.DataSource = table;

                GridView1.DataBind();
                txtTotAmt.Text = NetAmount.ToString();
                txtAmtwrds.Text = Convert.ToString(Rupees(Convert.ToInt64(NetAmount)));
                txtRate.Text = string.Empty;
                txtQuantity.Text = string.Empty;
            }
            else
            {
                PRODUCTGRID objproduct = listProductGrid.Where(p => p.SNO == RowNO).First();
                NetAmount = (NetAmount - objproduct.AMOUNT);
                objproduct.PRODUCT_TYPE = ddlProduct.SelectedItem.ToString();
                objproduct.PRODUCT_TYPE_ID = ddlProduct.SelectedValue.ToString();
                objproduct.PRODUCT_SUBTYPE = ddlSubProduct.SelectedItem.ToString();
                objproduct.PRODUCT_SUBTYPE_ID = ddlSubProduct.SelectedValue.ToString();
                objproduct.RATE = Convert.ToDecimal(txtRate.Text.Trim());
                objproduct.QUANTITY = Convert.ToDecimal(txtQuantity.Text.Trim());
                objproduct.AMOUNT = (Convert.ToDecimal(txtRate.Text.Trim()) * Convert.ToDecimal(txtQuantity.Text.Trim()));

                NetAmount = NetAmount + objproduct.AMOUNT;

                btnAdd.Text = "Add";
                txtRate.Text = string.Empty;
                txtQuantity.Text = string.Empty;
                GridView1.DataSource = listProductGrid;

                GridView1.DataBind();
                txtTotAmt.Text = NetAmount.ToString();
                txtAmtwrds.Text = Convert.ToString(Rupees(Convert.ToInt64(NetAmount)));
                PageStatus = RowStatusType.NEW;

            }

        }
    }