Skip to content

Commit

Permalink
Modified sample for IncomeTaxEmailDistribution
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohan2401 committed Nov 6, 2023
1 parent 6af8fb0 commit 95fb41d
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 31 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Form1()

private void button1_Click(object sender, EventArgs e)
{
string panColumnId = panColumnIdTxtBox.Text.Trim('"');
string tinColumnId = panColumnIdTxtBox.Text.Trim('"');

string emailColumnId = emailColumnIdTxtBox.Text.Trim('"');

Expand Down Expand Up @@ -60,42 +60,45 @@ private void button1_Click(object sender, EventArgs e)

int startRow = used.Row + 1;
int endRow = used.LastRow;
int statusColumn = used.LastColumn + 1;


for(int row = startRow;row <= endRow;row++)
{
if (worksheet.Range[row, 10].Value == "Sent")
//Check the automation status of the tax payer report
if (worksheet.Range[row, statusColumn].Value == "Sent")
{
continue;
}

//Converting the Column Id to Column Index
IRange panRange = worksheet[panColumnId + row.ToString()];
IRange tinRange = worksheet[tinColumnId + row.ToString()];

string panID = worksheet.Range[row, panRange.Column].Value;
string tinID = worksheet.Range[row, tinRange.Column].Value;

if(string.IsNullOrEmpty(panID))
if(string.IsNullOrEmpty(tinID))
{
worksheet[row, 10].Value = "PAN not found";
worksheet[row, statusColumn].Value = "TIN not found";
continue;
}

IRange emailRange = worksheet[emailColumnId + row.ToString()];

string emailId = worksheet.Range[row, emailRange.Column].Value;

string partAPath = partAPathFiles.Where(x => x.Contains(panID + "_")).FirstOrDefault();
string partAPath = partAPathFiles.Where(x => x.Contains(tinID + "_")).FirstOrDefault();

if (partAPath == null)
{
worksheet[row, 10].Value = "Part A File not found";
worksheet[row, statusColumn].Value = "Part A File not found";
continue;
}

string partBPath = partBPathFiles.Where(x => x.Contains(panID + "_")).FirstOrDefault();
string partBPath = partBPathFiles.Where(x => x.Contains(tinID + "_")).FirstOrDefault();

if (partBPath == null)
{
worksheet[row, 10].Value = "Part B File not found";
worksheet[row, statusColumn].Value = "Part B File not found";
continue;
}
try
Expand All @@ -109,15 +112,17 @@ private void button1_Click(object sender, EventArgs e)

SendEMail(from, emailId, subject, mailBody, partAPath, partBPath);

worksheet[row, 10].Value = "Sent";
worksheet[row, statusColumn].Value = "Sent";
}
catch(Exception ex){
worksheet[row, 10].Value = ex.ToString();
worksheet[row, statusColumn].Value = ex.ToString();
}
}

Thread.Sleep(1000);

// Saving the Workbook containing successful and failed records

string filePath = Path.GetFileNameWithoutExtension(excelFilePath) + "_Updated_" + DateTime.Now.ToString().Replace(":", "-") + Path.GetExtension(excelFilePath);

workbook.SaveAs(filePath);
Expand Down Expand Up @@ -151,5 +156,39 @@ private static void SendEMail(string from, string recipients, string subject, st
client.Send(emailMessage);
}
}

private void button2_Click(object sender, EventArgs e)
{
DialogResult result = this.openFileDialog1.ShowDialog();
// if a file is selected
if (result == DialogResult.OK)
{
// Set the selected file URL to the textbox
this.excelPathTxtBox.Text = this.openFileDialog1.FileName;
}
}

private void button1_Click_1(object sender, EventArgs e)
{
DialogResult result = this.folderBrowserDialog1.ShowDialog();
// if a file is selected
if (result == DialogResult.OK)
{
// Set the selected file URL to the textbox
this.partAPathTxtBox.Text = this.folderBrowserDialog1.SelectedPath;
}
}

private void button3_Click(object sender, EventArgs e)
{

DialogResult result = this.folderBrowserDialog1.ShowDialog();
// if a file is selected
if (result == DialogResult.OK)
{
// Set the selected file URL to the textbox
this.partBPathTxtBox.Text = this.folderBrowserDialog1.SelectedPath;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>187, 17</value>
</metadata>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Syncfusion.Compression.Base, Version=22.1460.37.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Compression.Base.22.1.37\lib\net46\Syncfusion.Compression.Base.dll</HintPath>
<Reference Include="Syncfusion.Compression.Base, Version=23.1460.43.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Compression.Base.23.1.43\lib\net46\Syncfusion.Compression.Base.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.Licensing, Version=22.1460.37.0, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Licensing.22.1.37\lib\net46\Syncfusion.Licensing.dll</HintPath>
<Reference Include="Syncfusion.Licensing, Version=23.1460.43.0, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Licensing.23.1.43\lib\net46\Syncfusion.Licensing.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.XlsIO.Base, Version=22.1460.37.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.XlsIO.WinForms.22.1.37\lib\net46\Syncfusion.XlsIO.Base.dll</HintPath>
<Reference Include="Syncfusion.XlsIO.Base, Version=23.1460.43.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.XlsIO.WinForms.23.1.43\lib\net46\Syncfusion.XlsIO.Base.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
Expand Down Expand Up @@ -110,6 +110,17 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Data\Part A\D00012_PartA.pdf" />
<None Include="Data\Part A\D00013_PartA.pdf" />
<None Include="Data\Part A\D00014_PartA.pdf" />
<None Include="Data\Part A\D00015_PartA.pdf" />
<None Include="Data\Part A\D00016_PartA.pdf" />
<None Include="Data\Part B\D00012_PartB.pdf" />
<None Include="Data\Part B\D00013_PartB.pdf" />
<None Include="Data\Part B\D00014_PartB.pdf" />
<None Include="Data\Part B\D00015_PartB.pdf" />
<None Include="Data\Part B\D00016_PartB.pdf" />
<None Include="Data\TaxPayerDetails.xlsx" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Syncfusion.Compression.Base" version="22.1.37" targetFramework="net472" />
<package id="Syncfusion.Licensing" version="22.1.37" targetFramework="net472" />
<package id="Syncfusion.XlsIO.WinForms" version="22.1.37" targetFramework="net472" />
<package id="Syncfusion.Compression.Base" version="23.1.43" targetFramework="net472" />
<package id="Syncfusion.Licensing" version="23.1.43" targetFramework="net472" />
<package id="Syncfusion.XlsIO.WinForms" version="23.1.43" targetFramework="net472" />
<package id="System.IO" version="4.3.0" targetFramework="net472" />
<package id="System.Net.Http" version="4.3.4" targetFramework="net472" />
<package id="System.Runtime" version="4.3.0" targetFramework="net472" />
Expand Down

0 comments on commit 95fb41d

Please sign in to comment.