/// <summary> /// On 'Print' button click to print /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvDailySalary.RowCount > 0) { DataSet ds = new DataSet(); CompanySP spCompany = new CompanySP(); DataTable dtblEmployee = spEmployee.EmployeeViewAllForDailySalaryReport(cmbEmployeeCode.Text, cmbDesignation.Text, Convert.ToDateTime(dtpFromDate.Text.ToString()), Convert.ToDateTime(dtpToDate.Text.ToString()), cmbStatus.Text); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); ds.Tables.Add(dtblCompany); ds.Tables.Add(dtblEmployee); frmReport frmReportObj = new frmReport(); frmReportObj.MdiParent = formMDI.MDIObj; frmReportObj.DailySalaryReport(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("DSR9 " + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On 'Print' button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvDailyAttendanceReport.RowCount > 0) { DataSet ds = new DataSet(); CompanySP spCompany = new CompanySP(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); ds.Tables.Add(dtblCompany); DailyAttendanceMasterSP spDailyAttendanceMaster = new DailyAttendanceMasterSP(); DataTable dtblAttendance = spDailyAttendanceMaster.DailyAttendanceViewForDailyAttendanceReport(dtpDate.Text.Trim(), cmbStatus.Text.Trim(), cmbEmployee.Text.Trim(), cmbDesignation.Text.Trim()); ds.Tables.Add(dtblAttendance); frmReport frmReportObj = new frmReport(); frmReportObj.MdiParent = formMDI.MDIObj; frmReportObj.DailyAttendanceReportPrinting(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("DAR:8" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On 'Print' button click to print /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvPayHead.RowCount > 0) { DataSet ds = new DataSet(); PayHeadSP spPayHead = new PayHeadSP(); DataTable dtbl = spPayHead.PayHeadViewAllForPayHeadReport(cmbPayHead.Text, cmbType.Text); CompanySP spCompany = new CompanySP(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); frmReport frmreport = new frmReport(); frmreport.MdiParent = formMDI.MDIObj; ds.Tables.Add(dtbl); ds.Tables.Add(dtblCompany); frmreport.PayHeadReport(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("PHR:7 " + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On 'Print' button clcik for print /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { DataSet ds = new DataSet(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); DataTable dtblDetails = new DataTable(); dtblDetails = dtblSalesQuotationReport.Copy(); if (dtblSalesQuotationReport.Rows.Count > 0) { ds.Tables.Add(dtblCompany); ds.Tables.Add(dtblDetails); frmReport frmRepor = new frmReport(); frmRepor.MdiParent = formMDI.MDIObj; frmRepor.SalesQuotationReportPrinting(ds, txtTotalAmount.Text); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("SQRP:12" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On print button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { DateTime FromDate = this.dtpFromDate.Value; DateTime ToDate = this.dtpToDate.Value; DataSet ds = new DataSet(); CompanySP spcompany = new CompanySP(); DataTable dtblProduct = dtbl.Copy(); DataTable dtblCompany = spcompany.CompanyViewDataTable(1); if (dgvProductBatch.Rows.Count > 0) { DataTable dtblNew = dtbl.Copy(); ds.Tables.Add(dtblCompany); ds.Tables.Add(dtblProduct); frmReport frmRepor = new frmReport(); frmRepor.MdiParent = formMDI.MDIObj; frmRepor.ProductBatchReportPrinting(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show(" PVSBR:9" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On 'Print' button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvBonusDeductionReport.RowCount > 0) { DataSet ds = new DataSet(); CompanySP spCompany = new CompanySP(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); ds.Tables.Add(dtblCompany); BonusDedutionSP spBonusDeduction = new BonusDedutionSP(); DataTable dtblBonusDeduction = spBonusDeduction.BonusDeductionReportGridFill(dtpFromDate.Text, dtpToDate.Text, dtpSalaryMonth.Text, cmbDesignation.Text, cmbEmployee.Text, strBonusOrDeduction); ds.Tables.Add(dtblBonusDeduction); frmReport frmReportObj = new frmReport(); frmReportObj.MdiParent = formMDI.MDIObj; frmReportObj.BonusDeductionReportPrinting(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("BDR:8" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On 'Print' button click to print /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvSalaryPackage.RowCount > 0) { frmReport frmreport = new frmReport(); DataSet ds = new DataSet(); SalaryPackageSP spSalaryPackage = new SalaryPackageSP(); CompanySP spCompany = new CompanySP(); DataTable dtblSalaryPackage = spSalaryPackage.SalaryPackageViewAllForSalaryPackageReport(cmbPackageName.Text, cmbStatus.Text); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); ds.Tables.Add(dtblSalaryPackage); ds.Tables.Add(dtblCompany); frmreport.MdiParent = formMDI.MDIObj; frmreport.SalaryPackageReport(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("SPD:9 " + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On 'Print' button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvContraReport.RowCount > 0) { DataSet ds = new DataSet(); CompanySP spCompany = new CompanySP(); frmReport reportobj = new frmReport(); ContraMasterSP spContraMaster = new ContraMasterSP(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); DataTable dtblCotraReport = spContraMaster.ContraReport(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), cmbVoucherType.Text, cmbCashOrBank.Text, strType); ds.Tables.Add(dtblCompany); ds.Tables.Add(dtblCotraReport); reportobj.MdiParent = formMDI.MDIObj; reportobj.ContraVoucherReport(ds); } else { MessageBox.Show("No data found", "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("CRT:12" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// on "print' button click for print /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvServiceReport.RowCount > 0) { DataSet dsServiceVoucherReport = new DataSet(); CompanySP spCompany = new CompanySP(); frmReport reportobj = new frmReport(); ServiceMasterSP spServiceMaster = new ServiceMasterSP(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); DataTable dtblServiceVoucherReport = spServiceMaster.ServiceReport(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), cmbVoucherType.Text, cmbCashOrParty.Text, cmbSalesman.Text); dsServiceVoucherReport.Tables.Add(dtblCompany); dsServiceVoucherReport.Tables.Add(dtblServiceVoucherReport); reportobj.MdiParent = formMDI.MDIObj; reportobj.ServiceVoucherReport(dsServiceVoucherReport); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("SVRT 15 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On 'Print' button click for print /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvMonthlySalary.Rows.Count > 0) { DataSet ds = new DataSet(); CompanySP spCompany = new CompanySP(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); ds.Tables.Add(dtblCompany); MonthlySalarySP spMonthlySalary = new MonthlySalarySP(); DataTable dtblMonthlySalary = spMonthlySalary.MonthlySalryViewAllForMonthlySalaryReports(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), cmbDesignation.Text, cmbEmployeeCode.Text, Convert.ToDateTime(dtpSalaryMonth.Value.ToString())); ds.Tables.Add(dtblMonthlySalary); frmReport frmReportObj = new frmReport(); frmReportObj.MdiParent = formMDI.MDIObj; frmReportObj.MonthlySalaryReportPrinting(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("MSR:9" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On 'Print' button click to print the data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvPurchaseReturnReport.Rows.Count > 0) { if (dgvPurchaseReturnReport.Rows.Count > 0) { DataSet dsPurchaseReturnReport = new DataSet(); CompanySP spCompany = new CompanySP(); DataTable dtblGrid = dtblReg.Copy(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); dsPurchaseReturnReport.Tables.Add(dtblGrid); dsPurchaseReturnReport.Tables.Add(dtblCompany); frmReport frmRepor = new frmReport(); frmRepor.MdiParent = formMDI.MDIObj; frmRepor.PurchaseReturnReportPrinting(dsPurchaseReturnReport, txtTotalAmount.Text); } } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("PRRT:13" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Print button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click_1(object sender, EventArgs e) { try { PhysicalStockMasterSP spPhysicalStockMaster = new PhysicalStockMasterSP(); if (dgvPhysicalStockReport.RowCount > 0) { DataSet ds = new DataSet(); CompanySP spCompany = new CompanySP(); frmReport reportobj = new frmReport(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); DataTable dtblPhysicalStockReport = spPhysicalStockMaster.PhysicalStockReportFill(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), txtVoucherNo.Text.Trim(), txtProductName.Text.Trim(), Convert.ToDecimal(cmbProductCode.SelectedValue), Convert.ToDecimal(cmbVoucherType.SelectedValue)); ds.Tables.Add(dtblCompany); ds.Tables.Add(dtblPhysicalStockReport); reportobj.MdiParent = formMDI.MDIObj; reportobj.PhysicalStockReport(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("PSRT:6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On 'Print' button click to take print /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvEmployee.RowCount > 0) { DataSet ds = new DataSet(); CompanySP spCompany = new CompanySP(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); ds.Tables.Add(dtblCompany); EmployeeSP spEmployee = new EmployeeSP(); DataTable dtblEmployee = spEmployee.EmployeeViewAllEmployeeReport(cmbDesigantion.Text, cmbEmployee.Text, cmbStatus.Text); ds.Tables.Add(dtblEmployee); frmReport frmReportObj = new frmReport(); frmReportObj.MdiParent = formMDI.MDIObj; frmReportObj.EmployeeReportPrinting(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("ER9" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On 'Print' button click to take print /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvAdvancePayment.Rows.Count > 0) { DataSet ds = new DataSet(); CompanySP spCompany = new CompanySP(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); ds.Tables.Add(dtblCompany); AdvancePaymentSP spAdvancePayment = new AdvancePaymentSP(); DataTable dtblAdvancePayment = new DataTable(); dtblAdvancePayment = spAdvancePayment.AdvancePaymentViewAllForAdvancePaymentReport(dtpFrmDate.Value, dtpToDate.Value, cmbEmployeeCode.Text, DateTime.Parse(dtpSalaryMonth.Text.ToString())); ds.Tables.Add(dtblAdvancePayment); frmReport frmReportObj = new frmReport(); frmReportObj.MdiParent = formMDI.MDIObj; frmReportObj.AdvancePaymentReportPrinting(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("APR:8" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public List <DataTable> CompanyViewDataTable(decimal companyId) { CompanySP spCompany = new CompanySP(); List <DataTable> listObj = new List <DataTable>(); try { listObj = spCompany.CompanyViewDataTable(companyId); } catch (Exception ex) { MessageBox.Show("CB:7" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(listObj); }
/// <summary> /// On print button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvPriceList.Rows.Count > 0) { frmReport frmRepor = new frmReport(); frmRepor.MdiParent = formMDI.MDIObj; DataTable dtblOption = new DataTable(); dtblOption.Columns.Add("PurchaseRate", typeof(String)); dtblOption.Columns.Add("SalesRate", typeof(String)); dtblOption.Columns.Add("LastSalesRate", typeof(String)); dtblOption.Columns.Add("StandardRate", typeof(String)); dtblOption.Columns.Add("MRP", typeof(String)); dtblOption.Columns.Add("Price", typeof(String)); DataRow dr = dtblOption.NewRow(); dr["PurchaseRate"] = cbxPurchaseRate.Checked?"True":"False"; dr["SalesRate"] = cbxSalesRate.Checked ? "True" : "False"; dr["LastSalesRate"] = cbxlastSalesRate.Checked ? "True" : "False"; dr["StandardRate"] = CbxStandardRate.Checked ? "True" : "False"; dr["MRP"] = cbxMrp.Checked ? "True" : "False"; dr["Price"] = "True"; dtblOption.Rows.Add(dr); DataSet ds = new DataSet(); CompanySP spCompany = new CompanySP(); PriceListSP spPriceList = new PriceListSP(); DataTable dtblPriceList = spPricingList.PriceListReportPrint(decGroupId, strProductName, decSizeId, decModelId, decPricingLevelId); DataTable dtblCompanyReport = spCompany.CompanyViewDataTable(1); DataTable dtblPriceListGridFill = dtblPriceListReport.Copy(); ds.Tables.Add(dtblCompanyReport); ds.Tables.Add(dtblPriceList); ds.Tables.Add(dtblOption); frmRepor.MdiParent = formMDI.MDIObj; frmRepor.PriceListReportPrinting(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show(" RPL17:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// ON 'Print' button click to take print /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvMonthlyAttendance.Rows.Count > 0) { DataSet ds = new DataSet(); CompanySP spCompany = new CompanySP(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); ds.Tables.Add(dtblCompany); DataTable dtblMonthlyAttendance = new DataTable(); dtblMonthlyAttendance.Columns.Add("SlNo", typeof(Int32)); dtblMonthlyAttendance.Columns.Add("employeeCode", typeof(string)); dtblMonthlyAttendance.Columns.Add("employeeName", typeof(string)); dtblMonthlyAttendance.Columns.Add("Present", typeof(string)); dtblMonthlyAttendance.Columns.Add("Absent", typeof(string)); foreach (DataGridViewRow dgvrow in dgvMonthlyAttendance.Rows) { dtblMonthlyAttendance.Rows.Add(); dtblMonthlyAttendance.Rows[dgvrow.Index]["SlNo"] = dgvrow.Cells["SlNo"].Value; dtblMonthlyAttendance.Rows[dgvrow.Index]["employeeCode"] = dgvrow.Cells["employeeCode"].Value; dtblMonthlyAttendance.Rows[dgvrow.Index]["employeeName"] = dgvrow.Cells["employeeName"].Value; dtblMonthlyAttendance.Rows[dgvrow.Index]["Present"] = dgvrow.Cells["Present"].Value; dtblMonthlyAttendance.Rows[dgvrow.Index]["Absent"] = dgvrow.Cells["Absent"].Value; } ds.Tables.Add(dtblMonthlyAttendance); frmReport frmReportObj = new frmReport(); frmReportObj.MdiParent = formMDI.MDIObj; frmReportObj.MonthlyAttendancePrinting(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("MAR15 " + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to print partyaddress book /// </summary> public void Print() { try { if (dvgPartyAddressBook.RowCount > 0) { DataSet ds = new DataSet(); CompanySP spCompany = new CompanySP(); frmReport reportobj = new frmReport(); AccountLedgerSP spAccountLedger = new AccountLedgerSP(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); DataTable dtbl = spAccountLedger.PartyAddressBookPrint(cmbAccountGroup.Text, txtMobile.Text, txtPhone.Text, txtEmail.Text, txtLedgerName.Text); ds.Tables.Add(dtblCompany); ds.Tables.Add(dtbl); reportobj.MdiParent = formMDI.MDIObj; reportobj.PartyAddressBookPrint(ds); } } catch (Exception ex) { MessageBox.Show("PAB:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On 'Print' button click to Print /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvSalaryPackageDetails.RowCount > 0) { DataTable dtblOther = new DataTable(); frmReport frmreport = new frmReport(); DataSet ds = new DataSet(); CompanySP spCompany = new CompanySP(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); SalaryPackageDetailsSP spSalaryPackageDetails = new SalaryPackageDetailsSP(); DataTable dtbl = spSalaryPackageDetails.SalaryPackageDetailsForSalaryPackageDetailsReport(cmbSalaryPackage.Text); ds.Tables.Add(dtblCompany); ds.Tables.Add(dtbl); ds.Tables.Add(dtblOther); DataColumn dc = new DataColumn("Addition", typeof(decimal)); dtblOther.Columns.Add(dc); dc = new DataColumn("Deduction", typeof(decimal)); dtblOther.Columns.Add(dc); DataRow dr = dtblOther.NewRow(); dr[0] = decCountAdditon; dr[1] = decCountDeduction; dtblOther.Rows.InsertAt(dr, 0); frmreport.MdiParent = formMDI.MDIObj; frmreport.SalaryPackageDetailsReport(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("SPDR:7" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void ExportExcel(DataGridView dgv, string rptName, int inFirstRow, int inFirstCol, string Format, object dtFromDate, object dtToDate, string header)//, string credit, string debit, string closing) { try { if (CheckWhetherOfficeInstalled()) { int inColN = 1; Cursor.Current = Cursors.WaitCursor; string strName = "", strAddress = "", strPhone = ""; Excel.Range range = null; Excel.Application excel = new Excel.Application(); Excel.Workbook wb = excel.Workbooks.Add(Excel.XlSheetType.xlWorksheet); Excel.Worksheet ws = (Excel.Worksheet)excel.ActiveSheet; CompanySP spCompany = new CompanySP(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); //BranchInfo InfoBranch = new BranchInfo(); //BranchSP SpBranch = new BranchSP(); // InfoBranch = SpBranch.BranchView(PublicVariables._branchId); strAddress = dtblCompany.Rows[0].ItemArray[3].ToString().Replace("\r\n", " "); strPhone = dtblCompany.Rows[0].ItemArray[4].ToString(); strName = dtblCompany.Rows[0].ItemArray[1].ToString(); //BranchInfo InfoBranch = new BranchInfo(); //BranchSP SpBranch = new BranchSP(); //InfoBranch = SpBranch.BranchView(PublicVariables._branchId); //strAddress = InfoBranch.Address.Replace("\r\n", " "); //if (InfoBranch.PhoneNo == "") //{ // strPhone = InfoBranch.Mobile; //} //else //{ // strPhone = InfoBranch.PhoneNo; //} //strName = InfoBranch.BranchName; //**************Report Header *************************************** //range = (Excel.Range)ws.Cells[1, 1]; range = ws.get_Range("A1", "I1"); range.MergeCells = true; range.Font.Size = 15; range.RowHeight = 27; range.Interior.Color = ColorTranslator.ToWin32(Color.LightGray); range.Cells.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; range.Cells.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter; range.Value2 = strName; range = ws.get_Range("A2", "I2"); range.MergeCells = true; range.Font.Size = 10; range.Cells.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; range.Value2 = strAddress; range = ws.get_Range("A3", "I3"); range.MergeCells = true; range.Font.Size = 10; range.Cells.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; range.Value2 = "Phone No :" + strPhone; range = ws.get_Range("A5", "G5"); range.MergeCells = true; range.Font.Size = 11; range.Value2 = rptName; range.Font.Underline = true; range.Font.Bold = true; range.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; range = ws.get_Range("A6", "G6"); range.MergeCells = true; //range.Cells.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; range.Font.Size = 11; if (dtFromDate != null && dtToDate != null) { range.Value2 = "(" + DateTime.Parse(dtFromDate.ToString()).Date.ToString("dd-MMM-yyyy") + " To " + DateTime.Parse(dtToDate.ToString()).Date.ToString("dd-MMM-yyyy") + ")"; } else if (dtFromDate != null) { range.Value2 = DateTime.Parse(dtFromDate.ToString()).Date.ToString("dd-MMM-yyyy"); } range.Cells.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; range.MergeCells = true; range.Font.Bold = true; range = ws.get_Range("H5", "H5"); range.Value2 = "Date :"; range.Font.Bold = true; range = ws.get_Range("I5", "I5"); range.Value2 = PublicVariables._dtCurrentDate.Date.ToString("dd-MMM-yyyy"); range.Font.Bold = true; int inNewRow = 0; inNewRow = inFirstRow; for (int inRow = inFirstRow; inRow < dgv.Rows.Count; inRow++) { if (dgv.Rows[inRow].Visible != false) { for (int inCol = inFirstCol; inCol < dgv.Columns.Count; inCol++) { if (inRow == 0) { if (dgv.Columns[inCol].Visible == true) { range = (Excel.Range)ws.Cells[inNewRow + 8, inColN]; range.Font.Bold = true; range.Interior.Color = ColorTranslator.ToWin32(Color.LightGray); range.Value2 = dgv.Columns[inCol].HeaderText; } } range = (Excel.Range)ws.Cells[inNewRow + 9, inColN]; if (dgv[inCol, inRow].Style.Font != null) { if (dgv[inCol, inRow].Style.Font.Bold) { range.Font.Bold = true; } } if (dgv.Rows[inRow].DefaultCellStyle.BackColor == Color.LightSkyBlue) { range.Font.Bold = true; range.Interior.Color = ColorTranslator.ToWin32(Color.LightGray); } if (dgv.Rows[inRow].DefaultCellStyle.ForeColor == Color.Red) { range.Font.Bold = true; range.Interior.Color = ColorTranslator.ToWin32(Color.LightGray); } //if (dgv.Rows[inRow].Visible != false) //{ if (dgv.Columns[inCol].Visible == true) { range.BorderAround(Excel.XlLineStyle.xlContinuous, Excel.XlBorderWeight.xlHairline, Excel.XlColorIndex.xlColorIndexAutomatic, 1); if (dgv[inCol, inRow].Value != null) { string str = dgv[inCol, inRow].Value.ToString(); try { if (dgv.Columns[inCol].HeaderText.Replace(" ", "").ToLower() == "phoneno" || dgv.Columns[inCol].HeaderText.Replace(" ", "").ToLower() == "phonenumber") { range.NumberFormat = "@"; } else { decimal.Parse(str); decimal dc = Math.Round(decimal.Parse(str), 2); str = dc.ToString(); if (dgv.Columns[inCol].Name.ToLower() == "debit" || dgv.Columns[inCol].Name.ToLower() == "credit") { range.NumberFormat = "#00.00#"; } else { range.NumberFormat = "General"; } } } catch (Exception) { try { DateTime.Parse(str); range.NumberFormat = "dd-MMM-yyyy"; range.NumberFormat = "General"; } catch (Exception) { range.NumberFormat = "@"; } } if (str.Contains("Dr") || str.Contains("Cr")) { range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight; } //try //{ // if (dgv.Columns[inCol].HeaderText.Replace(" ", "").ToLower() == "phoneno" || dgv.Columns[inCol].HeaderText.Replace(" ", "").ToLower() == "phonenumber") // range.NumberFormat = "@"; // else // { // decimal.Parse(str); // decimal dc = Math.Round(decimal.Parse(str), 2); // str = dc.ToString(); // } //} //catch (Exception) //{ // try // { // DateTime.Parse(str); // range.NumberFormat = "dd-MMM-yyyy"; // range.NumberFormat = "General"; // } // catch (Exception) // { // //range.NumberFormat = "@"; // range.NumberFormat = "General"; // } //} //------------------------------------ //------------------------------------ range.Value2 = str;// dgv[inCol, inRow].Value; } inColN++; } //} } inColN = 1; inNewRow++; } } inNewRow = inNewRow + 10; ws.Columns.AutoFit(); if (Format == "Excel") { excel.Visible = true; } //else if (Format == "Html") //{ // //***********Deleting all format************* // ws.Columns.AutoFit(); // FileInfo infoHtml = new FileInfo(Application.StartupPath + "\\Report.html"); // if (infoHtml.Exists) // { // infoHtml.Delete(); // } // //******************************************* // ws.SaveAs(Application.StartupPath + "\\Report.html", Excel.XlFileFormat.xlHtml, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value); // excel.Quit(); // System.Diagnostics.Process.Start("IExplore.exe", Application.StartupPath + "\\Report.html"); //} Cursor.Current = Cursors.Default; } else { MessageBox.Show("Install office", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }