protected void imgBtnReport_Click(object sender, ImageClickEventArgs e) { string srno = txtSRNo.Text; int sno; string party = "", share = "", action = "", idf = "", mdoc = "", targetdt = "", actualdt = "", status = "", remarks = "", att = "", intdt = ""; con.Open(); SqlCommand cmd = new SqlCommand("select * from tbl_trx_servicerequest where SRNo='" + srno + "'", con); SqlDataReader dr = cmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { new DataColumn("SRNO"), new DataColumn("SNO"), new DataColumn("IDF"), new DataColumn("Attorney"), new DataColumn("Party"), new DataColumn("Action"), new DataColumn("Share"), new DataColumn("Mdoc"), new DataColumn("IntiDt"), new DataColumn("TargetDt"), new DataColumn("ActualDt"), new DataColumn("Status"), new DataColumn("Remarks") }); while (dr.Read()) { if (!dr.IsDBNull(1)) { sno = Int16.Parse(dr.GetString(1)); } else { sno = 0; } if (!dr.IsDBNull(2)) { idf = dr.GetString(2); } else { idf = ""; } if (!dr.IsDBNull(3)) { att = dr.GetString(3); } else { att = ""; } if (!dr.IsDBNull(4)) { party = dr.GetString(4); } else { party = ""; } if (!dr.IsDBNull(5)) { action = dr.GetString(5); } else { action = ""; } if (!dr.IsDBNull(6)) { share = dr.GetString(6); } else { share = ""; } if (!dr.IsDBNull(7)) { mdoc = dr.GetString(7); } else { mdoc = ""; } if (!dr.IsDBNull(8)) { intdt = dr.GetString(8); } else { intdt = ""; } if (!dr.IsDBNull(9)) { targetdt = dr.GetString(9); } else { targetdt = ""; } if (!dr.IsDBNull(10)) { actualdt = dr.GetString(10); } else { actualdt = ""; } if (!dr.IsDBNull(11)) { status = dr.GetString(11); } else { status = ""; } if (!dr.IsDBNull(12)) { remarks = dr.GetString(12); } else { remarks = ""; } dt.Rows.Add(srno, sno, idf, att, party, action, share, mdoc, intdt, targetdt, actualdt, status, remarks); // if (!dr.IsDBNull(13)) Pincode = dr.GetString(13); else Pincode = ""; } string docfilename = "Template for " + srno + ".docx"; if (dt.Rows.Count > 0) { LetterTemplateXML tt = new LetterTemplateXML(); tt.ProcessRequest(dt, docfilename); } con.Close(); }
protected void lbtnTerm_Click(object sender, EventArgs e) { using (con = new SqlConnection()) { string ContractNo = Request.QueryString["ContractNo"].ToString(); string AgreementNo = "", TechTransfer = "", Title = "", Scope = "", Coordinator = "", Party = "", Dept = "", Address1 = "", Address2 = "", City = "", State = "", Country = "", Pincode = ""; string sql = "select ContractNo,AgreementNo,TechTransfer,Title,Scope,CoordinatingPerson,Dept,Party,Address1,Address2,City,State,Country,Pincode from Agreement a inner join CompanyMaster cm on a.Party=cm.CompanyName where contractno='" + ContractNo + "'"; SqlCommand cmd = new SqlCommand(); con.ConnectionString = ConfigurationManager.ConnectionStrings["PATENTCN"].ConnectionString; con.Open(); cmd.CommandText = sql; cmd.CommandType = CommandType.Text; cmd.Connection = con; SqlDataReader dr; dr = cmd.ExecuteReader(); if (dr.Read()) { if (!dr.IsDBNull(1)) { AgreementNo = dr.GetString(1); } else { AgreementNo = ""; } if (!dr.IsDBNull(2)) { TechTransfer = dr.GetString(2); } else { TechTransfer = ""; } if (!dr.IsDBNull(3)) { Title = dr.GetString(3); } else { Title = ""; } if (!dr.IsDBNull(4)) { Scope = dr.GetString(4); } else { Scope = ""; } if (!dr.IsDBNull(5)) { Coordinator = dr.GetString(5); } else { Coordinator = ""; } if (!dr.IsDBNull(6)) { Dept = dr.GetString(6); } else { Dept = ""; } if (!dr.IsDBNull(7)) { Party = dr.GetString(7); } else { Party = ""; } if (!dr.IsDBNull(8)) { Address1 = dr.GetString(8); } else { Address1 = ""; } if (!dr.IsDBNull(9)) { Address2 = dr.GetString(9); } else { Address2 = ""; } if (!dr.IsDBNull(10)) { City = dr.GetString(10); } else { City = ""; } if (!dr.IsDBNull(11)) { State = dr.GetString(11); } else { State = ""; } if (!dr.IsDBNull(12)) { Country = dr.GetString(12); } else { Country = ""; } if (!dr.IsDBNull(13)) { Pincode = dr.GetString(13); } else { Pincode = ""; } } DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { new DataColumn("ContractNo"), new DataColumn("AgreementNo"), new DataColumn("TechTransfer"), new DataColumn("Title"), new DataColumn("Scope"), new DataColumn("Coordinator"), new DataColumn("Dept"), new DataColumn("Type"), new DataColumn("Amount"), new DataColumn("Duedate"), new DataColumn("Party"), new DataColumn("Address1"), new DataColumn("Address2"), new DataColumn("City"), new DataColumn("State"), new DataColumn("Country"), new DataColumn("Pincode"), new DataColumn("Term") }); LinkButton lbn = (LinkButton)sender; GridViewRow grow = (GridViewRow)lbn.NamingContainer; int i = Convert.ToInt32(grow.RowIndex); //LinkButton lbn = (LinkButton)row.FindControl("Event"); if (lbn != null) { string Type = grow.Cells[2].Text; string Duedate = grow.Cells[3].Text; string Amount = grow.Cells[5].Text; string Term = lbn.Text; dt.Rows.Add(ContractNo, AgreementNo, TechTransfer, Title, Scope, Coordinator, Dept, Type, Amount, Duedate, Party, Address1, Address2, City, State, Country, Pincode, Term); } string docfilename = "Template for " + ContractNo + ".docx"; if (dt.Rows.Count > 0) { LetterTemplateXML tt = new LetterTemplateXML(); tt.ProcessRequest(dt, docfilename); } } }