protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e) { string strMsg = string.Empty; if (e.CommandName == "cmdedit") { Response.Redirect("Invoice.aspx?q=" + e.CommandArgument, true); } if (e.CommandName == "cmddelete") { Int64 UserIdno = Convert.ToInt64(Session["UserIdno"]); InvoiceDetailsDAL obj1 = new InvoiceDetailsDAL(); Int32 intValue = obj1.Delete(Convert.ToInt32(e.CommandArgument), UserIdno, ApplicationFunction.ConnectionString()); obj1 = null; if (intValue > 0) { this.BindGrid(); strMsg = "Record deleted successfully."; txtReceiptNo.Focus(); } else { if (intValue == -1) { strMsg = "Record can not be deleted. It is in use."; } else { strMsg = "Record not deleted."; } } ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true); } //else if (e.CommandName == "cmdstatus") //{ // int intCityIdno = 0; // bool bStatus = false; // string[] strStatus = Convert.ToString(e.CommandArgument).Split(new char[] { '_' }); // if (strStatus.Length > 1) // { // intCityIdno = Convert.ToInt32(strStatus[0]); // if (Convert.ToBoolean(strStatus[1]) == true) // bStatus = false; // else // bStatus = true; // CityMastDAL objclsCityMaster = new CityMastDAL(); // int value = objclsCityMaster.UpdateStatus(intCityIdno, bStatus); // objclsCityMaster = null; // if (value > 0) // { // this.BindGrid(); // strMsg = "Status updated successfully."; // drpState.Focus(); // } // else // { // strMsg = "Status not updated."; // } // ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true); // } //} //drpState.Focus(); }
private void PrintInvoiceRpt(String HeadIdno, Int64 year, Int64 city) { DataSet CompDetl = SqlHelper.ExecuteDataset(ApplicationFunction.ConnectionString(), CommandType.Text, "select * from tblcompmast"); lblCompName.Text = lblsign.Text = Convert.ToString(CompDetl.Tables[0].Rows[0]["Comp_Name"]); lbltr.Text = Convert.ToString(CompDetl.Tables[0].Rows[0]["Adress1"]); lbladdr.Text = Convert.ToString(CompDetl.Tables[0].Rows[0]["Adress2"]); lblemail.Text = Convert.ToString(CompDetl.Tables[0].Rows[0]["Comp_Mail"]); lblpin.Text = Convert.ToString(CompDetl.Tables[0].Rows[0]["Pin_No"]); lblmob.Text = Convert.ToString(CompDetl.Tables[0].Rows[0]["Phone_Off"]); string Stat = Convert.ToString(CompDetl.Tables[0].Rows[0]["State_Idno"]); DataSet ds2 = new DataSet(); DataSet dsMain = new DataSet(); InvoiceDetailsDAL obj = new InvoiceDetailsDAL(); ManageInvoiceDetails MI = new ManageInvoiceDetails(); Int64 fromCity = city; Int64 year_idno = year; String InvoiceNo = HeadIdno; string Value = InvoiceNo; string[] Array1 = Value.Split(new char[] { ',' }); for (int i = 0; i < Array1.Length; i++) { ds2 = obj.Report(year_idno, Array1[i], fromCity, ApplicationFunction.ConnectionString()); if (i == 0) { dsMain = ds2; } else { dsMain.Tables[0].Merge(ds2.Tables[0]); } } if (dsMain != null && dsMain.Tables[0].Rows.Count > 0) { Repeater1.DataSource = dsMain.Tables[0]; Repeater1.DataBind(); lblcomp.Text = Convert.ToString(ds2.Tables[0].Rows[0]["Acnt_Name"]); lbladd.Text = Convert.ToString(ds2.Tables[0].Rows[0]["Address1"]); lbldate.Text = Convert.ToDateTime(ds2.Tables[0].Rows[0]["Inv_Date"]).ToString("dd-MM-yyyy"); lblbill.Text = Session["InvoiceNo"] as String; string acntstateid = Convert.ToString(ds2.Tables[0].Rows[0]["State_Idno"]); double total = Convert.ToDouble(lbltotal.Text); if (Stat == acntstateid) { lblbillamnt.Text = total.ToString("N2"); lblsgstamnt.Text = string.Format("{0:0,0.00}", Convert.ToDouble(dsMain.Tables[0].Rows[0]["SGST_Amt"].ToString())); lblcgstamnt.Text = string.Format("{0:0,0.00}", Convert.ToDouble(dsMain.Tables[0].Rows[0]["CGST_Amt"].ToString())); lblsgstper.Text = "SGST " + Convert.ToDouble(dsMain.Tables[0].Rows[0]["SGST_Per"].ToString()) + " %"; lblcgstper.Text = "CGST " + Convert.ToDouble(dsMain.Tables[0].Rows[0]["CGST_Per"].ToString()) + " %"; lbligstper.Text = "IGST " + Convert.ToDouble(dsMain.Tables[0].Rows[0]["IGST_Per"].ToString()) + " %"; lbligstamnt.Text = "0.00"; double sgst = Convert.ToDouble(lblsgstamnt.Text); double cgst = Convert.ToDouble(lblcgstamnt.Text); double TotalAmount = Convert.ToDouble(total + sgst + cgst); lblTotalAmount.Text = TotalAmount.ToString("N2"); string[] str1 = TotalAmount.ToString().Split('.'); string numbertoent = NumberToText(Convert.ToInt32(str1[0])); lblword.Text = numbertoent + " Only"; trigst.Visible = false; } else { lblbillamnt.Text = total.ToString("N2"); lblsgstper.Text = "SGST " + Convert.ToDouble(dsMain.Tables[0].Rows[0]["SGST_Per"].ToString()) + " %"; lblcgstper.Text = "CGST " + Convert.ToDouble(dsMain.Tables[0].Rows[0]["CGST_Per"].ToString()) + " %"; lblsgstamnt.Text = "0.00"; lblcgstamnt.Text = "0.00"; lbligstamnt.Text = string.Format("{0:0,0.00}", Convert.ToDouble(dsMain.Tables[0].Rows[0]["IGST_Amt"].ToString())); lbligstper.Text = "IGST " + Convert.ToDouble(dsMain.Tables[0].Rows[0]["IGST_Per"].ToString()) + " %"; double igst = Convert.ToDouble(lbligstamnt.Text); double TotalAmount = Convert.ToDouble(total + igst); lblTotalAmount.Text = TotalAmount.ToString("N2"); string[] str1 = TotalAmount.ToString().Split('.'); string numbertoent = NumberToText(Convert.ToInt32(str1[0])); lblword.Text = numbertoent + " Only"; trsgst.Visible = false; trcgst.Visible = false; } } }
private void BindGrid() { DataSet ds2 = new DataSet(); DataSet dsMain = new DataSet(); InvoiceDetailsDAL obj = new InvoiceDetailsDAL(); DateTime? dtfrom = null; DateTime? dtto = null; if (string.IsNullOrEmpty(Convert.ToString(txtReceiptDatefrom.Text)) == false) { dtfrom = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtReceiptDatefrom.Text)); } if (string.IsNullOrEmpty(Convert.ToString(txtReceiptDatefrom.Text)) == false) { dtto = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtReceiptDateto.Text)); } Int64 fromCity = Convert.ToInt64((ddlFromCity.SelectedIndex != -1) ? (ddlFromCity.SelectedValue) : "0"); Int32 year_idno = Convert.ToInt32(ddldateRange.SelectedValue); String InvoiceNo = Convert.ToString(txtReceiptNo.Text); if (InvoiceNo.Contains("-")) { String value = InvoiceNo; var lowEnd = value.Split('-')[0]; var highEnd = value.Split('-')[1]; int first = Convert.ToInt32(lowEnd); int last = Convert.ToInt32(highEnd); for (int i = first; i <= last; i++) { if (i == last) { ar += i; } else { var arr = (i + ", "); ar += arr; } } string val = ar; string[] Arr = val.Split(new char[] { ',' }); for (int l = 0; l < Arr.Length; l++) { ds2 = obj.SelectRep(year_idno, dtfrom, dtto, Arr[l], fromCity, ApplicationFunction.ConnectionString()); if (l == 0) { dsMain = ds2; } else { dsMain.Tables[0].Merge(ds2.Tables[0]); } grdMain.DataSource = dsMain.Tables[0]; grdMain.DataBind(); lblTotalRecord.Text = "T. Record (s): " + dsMain.Tables[0].Rows.Count; } lnkprint111.Visible = true; // imgBtnExcel.Visible = true; } else { string Value = InvoiceNo; string[] Array1 = Value.Split(new char[] { ',' }); for (int i = 0; i < Array1.Length; i++) { ds2 = obj.SelectRep(year_idno, dtfrom, dtto, Array1[i], fromCity, ApplicationFunction.ConnectionString()); if (i == 0) { dsMain = ds2; } else { dsMain.Tables[0].Merge(ds2.Tables[0]); } grdMain.DataSource = dsMain.Tables[0]; grdMain.DataBind(); lblTotalRecord.Text = "T. Record (s): " + dsMain.Tables[0].Rows.Count; } lnkprint111.Visible = true; // imgBtnExcel.Visible = true; } }