private void SetInitialRow() { try { DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add("#", typeof(int)); dt.Columns.Add("ItemId", typeof(Int32)); dt.Columns.Add("Item", typeof(string)); dt.Columns.Add("ItemDetailsId", typeof(Int32)); dt.Columns.Add("ItemDesc", typeof(string)); dt.Columns.Add("Unit", typeof(string)); dt.Columns.Add("Issue", typeof(decimal)); dt.Columns.Add("Rate", typeof(decimal)); dt.Columns.Add("Amount", typeof(decimal)); dt.Columns.Add("Consumption", typeof(decimal)); dt.Columns.Add("ConsumptionAmt", typeof(decimal)); dt.Columns.Add("Pending", typeof(decimal)); dt.Columns.Add("PendingAmount", typeof(decimal)); dt.Columns.Add("LocID", typeof(Int32)); dt.Columns.Add("UnitId", typeof(Int32)); dt.Columns.Add("Location", typeof(string)); dr = dt.NewRow(); dr["#"] = 0; dr["ItemId"] = 0; dr["Item"] = ""; dr["ItemDetailsId"] = 0; dr["ItemDesc"] = ""; dr["Unit"] = ""; dr["Issue"] = 0; dr["Rate"] = 0; dr["Amount"] = 0; dr["Consumption"] = 0; dr["ConsumptionAmt"] = 0; dr["Pending"] = 0; dr["PendingAmount"] = 0; dr["LocID"] = 0; dr["UnitId"] = 0; dr["Location"] = ""; dt.Rows.Add(dr); ViewState["CurrentTable"] = dt; GridIssueDetails.DataSource = dt; GridIssueDetails.DataBind(); } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void ReportGrid1_RowCommand(object sender, GridViewCommandEventArgs e) { string Rdb = string.Empty; try { switch (e.CommandName) { case ("Select"): { if (Convert.ToInt32(e.CommandArgument) != 0) { ViewState["ID"] = Convert.ToInt32(e.CommandArgument); Ds = Obj_ConsumeMaster.GetRecordForEdit(Convert.ToInt32(e.CommandArgument), out StrError); if (Ds.Tables.Count > 0 && Ds.Tables[0].Rows.Count > 0) { TxtConsumptionNo.Text = Ds.Tables[0].Rows[0]["ConsumptionNo"].ToString(); TxtDate.Text = Ds.Tables[0].Rows[0]["ConsumptionDate"].ToString(); LBLISSUENO.Text = Ds.Tables[0].Rows[0]["IssueId"].ToString(); } if (Ds.Tables.Count > 0 && Ds.Tables[1].Rows.Count > 0) { GridIssueDetails.DataSource = Ds.Tables[1]; GridIssueDetails.DataBind(); ViewState["CurrentTable"] = Ds.Tables[1]; EnableControl(false); } else { MakeEmptyForm(); } Ds = null; Obj_ConsumeMaster = null; BtnUpdate.Visible = true; BtnSave.Visible = false; } break; } } } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void BtnShowIssue_Click(object sender, EventArgs e) { try { DataSet DsGrd = new DataSet(); StrCondition = string.Empty; BtnSave.Visible = true; BtnUpdate.Visible = false; if (Convert.ToInt32(ddlIssueNo.SelectedValue) > 0) { DsGrd = Obj_ConsumeMaster.GetDetailOnCondForIssue(Convert.ToInt32(ddlIssueNo.SelectedValue), LocationId, out StrError); if (DsGrd.Tables.Count > 0 && DsGrd.Tables[0].Rows.Count > 0) { issusecond = 1; GridIssueDetails.DataSource = DsGrd; GridIssueDetails.DataBind(); ViewState["CurrentTableRequisition"] = DsGrd; ((TextBox)GridIssueDetails.Rows[0].FindControl("txtGrdConsumption")).Focus(); } else { GridIssueDetails.DataSource = null; GridIssueDetails.DataBind(); ddlIssueNo.Focus(); } DsGrd = null; } else { ddlIssueNo.Focus(); } } catch (Exception ex) { } }