<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PackingLIst_of_Goods.aspx.cs" MasterPageFile="~/Master.Master" Inherits="Billing_System.Packing.PackingLIst_of_Goods" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style1
{
width: 213px;
}
.style2
{
width: 100%;
float: left;
}
</style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" class="wel_1" id="main_header">
<div style="padding-top:08px; padding-left:10px;">
PACKING LIST ...
</div>
</td>
</tr>
</table>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div>
<table style="width:100%;">
<tr>
<td class="style1">
Packing List No.</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style1">
M/S Name</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</td>
<td>
<asp:LinkButton ID="LinkButton2" runat="server">Add more M/s</asp:LinkButton>
</td>
</tr>
<tr>
<td class="style1">
SubName/Billing Name</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
</td>
<td>
<asp:LinkButton ID="LinkButton3" runat="server">Add more Billing Information</asp:LinkButton>
</td>
</tr>
<tr>
<td class="style1">
Specification</td>
<td>
<asp:DropDownList ID="ddlSpecification" runat="server">
</asp:DropDownList>
</td>
<td>
code
<asp:DropDownList ID="DropDownList4" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style1">
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</div>
<div>
<table align="left" cellpadding="0" cellspacing="0" class="style2">
<tr>
<td>
Select</td>
<td>
Qty/GrossWt</td>
<td>
Unit</td>
<td>
LessWt1</td>
<td>
LessWt2</td>
<td>
LessWt3</td>
<td>
LessWt4</td>
<td>
LessWt5</td>
<td>
TotalLessWt</td>
<td>
NetWt</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="ddlSelectBK" runat="server">
<asp:ListItem>Bundle</asp:ListItem>
<asp:ListItem>Katta</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="txtQTYgrosswt" runat="server" Width="100px"></asp:TextBox>
</td>
<td>
<asp:DropDownList ID="ddlUnit" runat="server">
<asp:ListItem>kgs</asp:ListItem>
<asp:ListItem>gms</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="txtLessWt1" runat="server" Width="50px" Height="22px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txtLessWt2" runat="server" Width="50px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txtLessWt3" runat="server" Width="50px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txtLessWt4" runat="server" Width="50px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txtLessWt5" runat="server" Width="50px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txtTotalLessWt" runat="server" Width="100px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txtNetWt" runat="server" Width="100px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" Text="ADD" onclick="Button1_Click"
style="width: 41px" />
</td>
<td colspan="9">
<asp:Label ID="lblTips" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
<td colspan="9">
</td>
<td>
</td>
</tr>
<tr>
<td colspan="11">
<div>
<asp:GridView ID="MainGridView" runat="server" AutoGenerateColumns="False"
CellPadding="6" Width="95%" Font-Names="Arial" GridLines="None" BorderColor="#000000"
BorderStyle="Solid" BorderWidth="1px">
<Columns>
<asp:TemplateField HeaderText="Specification and Packing List">
<ItemTemplate>
<asp:Label runat="server" ID="lblCategoryName" Text='<%# Eval("Specification") %>'
Font-Bold="True" Font-Size="12pt" />
<asp:GridView ID="InnerGridView" runat="server" CellPadding="4" Width="100%"
DataSource='<%# GetProductsByCategory(Eval ("SpId").ToString()) %>'
BorderStyle="Solid" BorderWidth="1px" Font-Size="8pt"
BorderColor="#336699" GridLines="Horizontal"
onrowdatabound="InnerGridView_RowDataBound">
<HeaderStyle BackColor="#336699" Font-Bold="True" ForeColor="White" />
</asp:GridView>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle BackColor="#000000" Font-Bold="True" ForeColor="White" Font-Size="10pt" />
</asp:GridView>
</div>
</td>
</tr>
</table>
</div>
<%-- <div>
<table style="width:100%;">
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</div>--%>
</asp:Content>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Billing_System.Packing
{
public partial class PackingLIst_of_Goods : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["BillingConnectionString"].ToString());
DataUtility dut = new DataUtility();
DataTable dt = new DataTable();
DataTable myDt = new DataTable();//--creat table for grid
DataTable MsInfoTable = new DataTable();//---for ms hold info in table
DataTable Spdt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillSpecification();//---fill Specification
myDt = CreateDataTable();
Spdt = CreateDataTableSp();
ViewState["myDatatable"] = myDt;
ViewState["SpDatatable"] = Spdt;
}
}
private void FillSpecification()//---fill Specification
{
string spInfo = "SELECT * FROM SpecificationInformation";
ddlSpecification.DataSource = dut.GetDataTable(spInfo);
ddlSpecification.DataTextField = "Specification";
ddlSpecification.DataValueField = "id";
ddlSpecification.DataBind();
}
private DataTable CreateDataTable()
{//---Create datatable with datatype
DataTable myDataTable = new DataTable();
DataColumn myDataColumn;
//Specification/SelectBK/QtyGWt/Unit//TotalLess/Netwt
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.Int32");
myDataColumn.ColumnName = "id";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "SpId";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "SelectBK";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.Double");
myDataColumn.ColumnName = "QtyGWt";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "Unit";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn(); myDataColumn.DataType = Type.GetType("System.Double"); myDataColumn.ColumnName = "Lesswt1"; myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn(); myDataColumn.DataType = Type.GetType("System.Double"); myDataColumn.ColumnName = "Lesswt2"; myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn(); myDataColumn.DataType = Type.GetType("System.Double"); myDataColumn.ColumnName = "Lesswt3"; myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn(); myDataColumn.DataType = Type.GetType("System.Double"); myDataColumn.ColumnName = "Lesswt4"; myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn(); myDataColumn.DataType = Type.GetType("System.Double"); myDataColumn.ColumnName = "Lesswt5"; myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.Double");
myDataColumn.ColumnName = "TotalLess";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.Double");
myDataColumn.ColumnName = "Netwt";
myDataTable.Columns.Add(myDataColumn);
return myDataTable;
}
private void AddDataToTable(string Specification, string SelectBK, string QtyGWt, string Unit, string lesswt1, string lesswt2, string lesswt3, string lesswt4, string lesswt5, string TotalLess, string Netwt, DataTable myTable)
{
DataRow row;
row = myTable.NewRow();
//row["id"] = Guid.NewGuid().ToString();
row["id"] = myTable.Rows.Count + 1;
row["SpId"] =Convert.ToInt32(Specification);
row["SelectBK"] = SelectBK;
row["QtyGWt"] = QtyGWt;
row["Unit"] = Unit;
row["Lesswt1"] = lesswt1; row["Lesswt2"] = lesswt2; row["Lesswt3"] = lesswt3; row["Lesswt4"] = lesswt4; row["Lesswt5"] = lesswt5;
row["TotalLess"] = TotalLess;
row["Netwt"] = Netwt;
myTable.Rows.Add(row);
}
private void AddDataToTableSp(string Specification,string SpId, DataTable SpTable)
{
try
{
DataRow row;
row = SpTable.NewRow();
//row["id"] = Guid.NewGuid().ToString();
row["Specification"] = Specification;
row["SpId"] =Convert.ToInt32(SpId);
SpTable.Rows.Add(row);
}
catch (Exception)
{
// throw;
}
}
private DataTable CreateDataTableSp()
{//---Create datatable with datatype
DataTable SpDataTable = new DataTable();
DataColumn myDataColumn;
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "Specification";
SpDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.Int32");
myDataColumn.ColumnName = "SpId";
SpDataTable.Columns.Add(myDataColumn);
return SpDataTable;
}
protected void Button1_Click(object sender, EventArgs e)
{
//----Add Specification Item in dataset on fly
if (txtNetWt.Text.Trim() == "")
{
this.lblTips.Text = "You must fill all Information";
return;
}
else
{
AddDataToTable(this.ddlSpecification.SelectedValue.ToString(), this.ddlSelectBK.SelectedItem.Text.ToString(), this.txtQTYgrosswt.Text.Trim(), this.ddlUnit.SelectedItem.Text.Trim(), this.txtLessWt1.Text.Trim(), this.txtLessWt2.Text.Trim(), this.txtLessWt3.Text.Trim(), this.txtLessWt4.Text.Trim(), this.txtLessWt5.Text.Trim(), this.txtTotalLessWt.Text.Trim(), this.txtNetWt.Text.Trim(), (DataTable)ViewState["myDatatable"]);
AddDataToTableSp(this.ddlSpecification.SelectedItem.Text.ToString(),this.ddlSpecification.SelectedValue.ToString(), (DataTable)ViewState["SpDatatable"]);
DataTable uData = ((DataTable)ViewState["SpDatatable"]);
Int32 UID = Convert.ToInt32(uData.Select("Specification='" + ddlSpecification.SelectedItem.Text + "'").Count());
DataTable sf = ((DataTable)ViewState["SpDatatable"]);
sf.Columns["Specification"].Unique = true;
MainGridView.DataSource = sf;
MainGridView.DataBind();
}
}
public DataTable GetProductsByCategory(string SpId)
{
DataTable mf=new DataTable() ;
DataTable newTable = CreateDataTable();
if (SpId != null)
{
mf = ((DataTable)ViewState["myDatatable"]);
foreach (DataRow dr in mf.Select("SpId IN (" + SpId + ")"))
{
newTable.ImportRow(dr);
}
}
return newTable;
}
protected void InnerGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{//---Inner grid view Couman SpID Hide
e.Row.Cells[1].Visible = false;
}
}
}
No comments:
Post a Comment