protected void btnSave_Click(object sender, EventArgs e) { dtgridList = (DataTable)ViewState["dtgridList"]; string users = Session["id"].ToString(); FrameWork.DRSIForm drsi = new FrameWork.DRSIForm(); FrameWork.DRSISub drsisub = new DRSISub(); busDISRForm busDISR = new busDISRForm(); drsi.CustomerFKID = int.Parse(this.drpCustomer.SelectedValue); drsi.ProductFKID = int.Parse(this.drpProduct.SelectedValue); drsi.TotalPcs = lblPcs.Text; drsi.TotalUOM = lblUOM.Text; drsi.TotalWeight = lblWeight.Text; drsi.TotalUnitCost = txtCost.Text; drsi.TotalCost = lblTCost.Text; drsi.OrderBy = users; string x = busDISR.insertDRSI(drsi); foreach (DataRow dr in dtgridList.Rows) { drsisub.DRSiformID = int.Parse(x); drsisub.BatchNo = dr["BatchNo"].ToString(); drsisub.ModuleNo = dr["ModuleNo"].ToString(); drsisub.CageNo = dr["CageNo"].ToString(); drsisub.Weight = dr["Weight"].ToString(); drsisub.UnitOfMeasure = dr["UnitOfMeasure"].ToString(); busDISR.insertDRSIsub(drsisub); } }
public string insertDRSI(DRSIForm drsi) { string Message = string.Empty; int result = 0; con.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO [inventory].[dbo].DRSIForm ([CustomerFKID],[ProductFKID],[TotalPcs],[TotalUOM],[TotalWeight],[TotalUnitCost],[TotalCost]) VALUES (@CustomerFKID,@ProductFKID,@TotalPcs,@TotalUOM,@TotalWeight,@TotalUnitCost,@TotalCost)", con); cmd.Parameters.AddWithValue("@CustomerFKID", drsi.CustomerFKID); cmd.Parameters.AddWithValue("@ProductFKID", drsi.ProductFKID); cmd.Parameters.AddWithValue("@TotalPcs", drsi.TotalPcs); cmd.Parameters.AddWithValue("@TotalUOM", drsi.TotalUOM); cmd.Parameters.AddWithValue("@TotalWeight", drsi.TotalWeight); cmd.Parameters.AddWithValue("@TotalUnitCost", drsi.TotalUnitCost); cmd.Parameters.AddWithValue("@TotalCost", drsi.TotalCost); result = cmd.ExecuteNonQuery(); con.Close(); string query ="select top 1 ID from [DRSIForm] order by id desc"; DataTable dt = new DataTable("Customer"); dt.Clear(); dt = DataAccess.DBAdapter.GetRecordSet(query); if (dt.Rows.Count > 0) { Message = dt.Rows[0]["ID"].ToString(); } return Message; }
protected void btnSave_Click(object sender, EventArgs e) { dtgridList = (DataTable)ViewState["dtgridList"]; FrameWork.DRSIForm drsi = new FrameWork.DRSIForm(); FrameWork.DRSISub drsisub = new DRSISub(); busDISRForm busDISR = new busDISRForm(); drsi.CustomerFKID = int.Parse(this.drpCustomer.SelectedValue); drsi.ProductFKID = int.Parse(this.drpProduct.SelectedValue); drsi.TotalPcs = lblPcs.Text; drsi.TotalUOM = lblUOM.Text; drsi.TotalWeight = lblWeight.Text; drsi.TotalUnitCost = txtCost.Text; drsi.TotalCost = lblTCost.Text; string x = busDISR.insertDRSI(drsi); foreach (DataRow dr in dtgridList.Rows) { drsisub.DRSiformID = int.Parse(x); drsisub.BatchNo = dr["BatchNo"].ToString(); drsisub.ModuleNo = dr["ModuleNo"].ToString(); drsisub.CageNo = dr["CageNo"].ToString(); drsisub.Weight = dr["Weight"].ToString(); drsisub.UnitOfMeasure = dr["UnitOfMeasure"].ToString(); busDISR.insertDRSIsub(drsisub); } }
public FrameWork.DRSIForm[] allDrSIForm() { string query = "SELECT a.[ID] ,b.[Company],c.[ProductName],[TotalPcs],[TotalUOM],[TotalWeight],[TotalUnitCost],[TotalCost] FROM [inventory].[dbo].DRSIForm a inner join [Customers] b on a.CustomerFKID = b.ID inner join [Products] c on a.ProductFKID= c.ID"; DataTable table = new DataTable(); table = DataAccess.DBAdapter.GetRecordSet(query); FrameWork.DRSIForm[] dec = new FrameWork.DRSIForm[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { dec[i] = new FrameWork.DRSIForm(table.Rows[i]); } return(dec); }
public FrameWork.DRSIForm[] allDrSIForm() { string query = "SELECT a.[ID] ,b.[Company],c.[ProductName],[TotalPcs],[TotalUOM],[TotalWeight],[TotalUnitCost],[TotalCost] FROM [inventory].[dbo].DRSIForm a inner join [Customers] b on a.CustomerFKID = b.ID inner join [Products] c on a.ProductFKID= c.ID"; DataTable table = new DataTable(); table = DataAccess.DBAdapter.GetRecordSet(query); FrameWork.DRSIForm[] dec = new FrameWork.DRSIForm[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { dec[i] = new FrameWork.DRSIForm(table.Rows[i]); } return dec; }