protected void btnB2csAdd_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); lblB2csErrorMsg.Text = ""; if (ViewState["B2CSTable"] == null) { dt.Columns.Add("Type"); dt.Columns.Add("PlaceOfSupplyCode"); dt.Columns.Add("Place Of Supply"); dt.Columns.Add("Rate"); dt.Columns.Add("Taxable Value"); dt.Columns.Add("Cess Amount"); dt.Columns.Add("E-Commerce GSTIN"); dt.Columns.Add("ItemIGSTValue"); dt.Columns.Add("ItemCGSTValue"); dt.Columns.Add("ItemSGSTValue"); } else { dt = (DataTable)ViewState["B2CSTable"]; } DataRow dr = dt.NewRow(); dr["Type"] = ddlB2csType.SelectedItem.Text; dr["PlaceOfSupplyCode"] = ddlB2csPlaceOfSupply.Text; dr["Place Of Supply"] = ddlB2csPlaceOfSupply.SelectedItem.Text; dr["Rate"] = ddltxtB2csRate.SelectedItem.Text.ToString(); dr["Taxable Value"] = txtB2csTaxableValue.Text; dr["Cess Amount"] = txtB2csCessAmount.Text.Trim() == "" ? "0" : txtB2csCessAmount.Text.Trim(); dr["E-Commerce GSTIN"] = txtB2csEcommerceGstin.Text.ToString(); string GSTIN = Session["ClientGSTNNO"].ToString(); int stateCode = Convert.ToInt32(ddlB2csPlaceOfSupply.SelectedValue); int gst = Convert.ToInt32(GSTIN.Substring(0, 2)); if (gst != stateCode) { dr["ItemIGSTValue"] = ((Convert.ToDecimal(ddltxtB2csRate.SelectedItem.Text.ToString()) * Convert.ToDecimal(txtB2csTaxableValue.Text)) / 100).ToString(); dr["ItemCGSTValue"] = "0"; dr["ItemSGSTValue"] = "0"; } else { dr["ItemIGSTValue"] = "0"; dr["ItemCGSTValue"] = (((Convert.ToDecimal(ddltxtB2csRate.SelectedItem.Text.ToString()) * Convert.ToDecimal(txtB2csTaxableValue.Text)) / 100) / 2).ToString(); dr["ItemSGSTValue"] = (((Convert.ToDecimal(ddltxtB2csRate.SelectedItem.Text.ToString()) * Convert.ToDecimal(txtB2csTaxableValue.Text)) / 100) / 2).ToString();; } dt.Rows.Add(dr); ViewState["B2CSTable"] = dt; GridB2cs.DataSource = dt; GridB2cs.DataBind(); ClearB2cs(); }
protected void GridB2cs_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteRecords") { DataTable B2csTable = (DataTable)ViewState["B2CSTable"]; B2csTable.Rows.RemoveAt(int.Parse(e.CommandArgument.ToString())); ViewState["B2CSTable"] = B2csTable; GridB2cs.DataSource = B2csTable; GridB2cs.DataBind(); } }
protected void clearGrid() // clear all grid or view state all tab data { grdB2B.DataSource = null; grdB2B.DataBind(); GridB2cl.DataSource = null; GridB2cl.DataBind(); GridB2cs.DataSource = null; GridB2cs.DataBind(); GridCdnr.DataSource = null; GridCdnr.DataBind(); GridCdnur.DataSource = null; GridCdnur.DataBind(); GridExp.DataSource = null; GridExp.DataBind(); GridAt.DataSource = null; GridAt.DataBind(); GridAtAdj.DataSource = null; GridAtAdj.DataBind(); GridHsn.DataSource = null; GridHsn.DataBind(); GridExeMp.DataSource = null; GridExeMp.DataBind(); GridDocs.DataSource = null; GridDocs.DataBind(); ViewState["B2BTable"] = null; ViewState["B2ClTable"] = null; ViewState["B2CSTable"] = null; ViewState["CDNRTable"] = null; ViewState["CDNURTable"] = null; ViewState["ExpTable"] = null; ViewState["AtTable"] = null; ViewState["AtAdjTable"] = null; ViewState["HsnTable"] = null; ViewState["ExeMpTable"] = null; ViewState["DocsTable"] = null; ClearB2B(); ClearB2cl(); ClearB2cs(); ClearCdnur(); ClearExp(); ClearAt(); ClearDocs(); ClearAtAdj(); ClearExeMp(); ClearHsn(); ClearCdnr(); }