0% found this document useful (0 votes)
12 views16 pages

RMWire Report

Uploaded by

vishaldeepika248
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views16 pages

RMWire Report

Uploaded by

vishaldeepika248
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 16

using sims_web_api.

Dapper;
using sims_web_api.Dapper.Ds_GlobalReportsTableAdapters;
using sims_web_api.Dapper.DS_ReportDataTableAdapters;
using sims_web_api.Models;
using System.Data;
using System;
using System.Web.Http;
using System.Windows;
using System.Drawing.Drawing2D;
using System.Collections.Generic;
using sims_web_api.Comma;
using System.Data.SqlClient;
using System.Xml.Linq;

namespace sims_web_api.Controllers
{

public class RMWireReportController : ApiController


{
Comman ClCommon = new Comman();
private readonly Ds_GlobalReports _DsGlrpt;
private readonly DS_ReportData _DsRptdata;

private readonly APVEN1TableAdapter _apven;


private readonly Tbl_vendTableAdapter _tblvnd;

private readonly ImpWirePendTableAdapter _impwirepnd;


private readonly st_ItemSizeMasterTableAdapter _itmsz;
private readonly Ds_GradeTableAdapter _grade;
private readonly Ds_WireRoadTableAdapter _wroad;
private readonly Ds_WireTableAdapter _wire;
private readonly
Dapper.DS_ReportDataTableAdapters.st_ItemSizeMaster_WIRETableAdapter _wiresz;
private readonly DS_WIRE_GRADETableAdapter _wiregr;
private readonly ds_itmsznotfoundTableAdapter _itmnf;
private readonly rmgrade_localTableAdapter _GradeL;
private readonly rmGrade_ImportTableAdapter _GradeI;
private readonly Ds_WireRodGradeTableAdapter _wrgr11;
private readonly Import_ItmSzNtFoundTableAdapter _impitmntf;
private st_ItemSizeMaster_WIRE1TableAdapter _onlywiresz;

Ds_GlobalReports DsGlrpt = new Ds_GlobalReports();


Dapper.Ds_GlobalReportsTableAdapters.APVEN1TableAdapter apven = new
Dapper.Ds_GlobalReportsTableAdapters.APVEN1TableAdapter();

public RMWireReportController()
{
_DsGlrpt = new Ds_GlobalReports();
_DsRptdata = new DS_ReportData();
_apven = new APVEN1TableAdapter();
_tblvnd = new Tbl_vendTableAdapter();

_impwirepnd = new ImpWirePendTableAdapter();


_itmsz = new st_ItemSizeMasterTableAdapter();
_grade = new Ds_GradeTableAdapter();
_wroad = new Ds_WireRoadTableAdapter();
_wire = new Ds_WireTableAdapter();
_wiresz = new
Dapper.DS_ReportDataTableAdapters.st_ItemSizeMaster_WIRETableAdapter();
_wiregr = new DS_WIRE_GRADETableAdapter();
_itmnf = new ds_itmsznotfoundTableAdapter();
_GradeL = new rmgrade_localTableAdapter();
_GradeI = new rmGrade_ImportTableAdapter();
_wrgr11 = new Ds_WireRodGradeTableAdapter();
_impitmntf = new Import_ItmSzNtFoundTableAdapter();
_onlywiresz = new st_ItemSizeMaster_WIRE1TableAdapter();
}

DataTable dt = new DataTable();


string strvdcode = "";
int cntr = 0;
string strwpo = "";
string strwopo = "";
string impwire = "N";
string isexcelformat = "N";
string repoheading = "";
string flt = "";
int grvind = -1;

[HttpGet]
[Route("api/rmwirereport/checked")]
public IHttpActionResult WireRoad_Checked(string name, bool value)
{
try
{
if (value)
{
if (name == "WireRoad")
{
ProcessWireRoad();
}
else if (name == "Wire")
{
ProcessWire();
}
else if (name == "Import")
{
ProcessImport();
}

return Json(_DsGlrpt.Tbl_ven.Copy());
}

return Ok(new object[0]);


}
catch (Exception ex)
{
// Log the exception as needed
return Json(ex.Message.ToString());
}
}

private void ProcessWireRoad()


{
_apven.Fill(DsGlrpt.APVEN1);
impwire = "N";
repoheading = "PO Pending for Wire Rod";
AddRowsToTblVen(_DsGlrpt.APVEN1);
}

private void ProcessWire()


{
try
{

apven.Fill(DsGlrpt.APVEN1);
// _apven.Fill(_DsGlrpt.APVEN1);
repoheading = "PO Pending for Wire";
AddRowsToTblVen(DsGlrpt.APVEN1);
}
catch(Exception ex)
{
MessageBox.Show("Error : " + ex.ToString().Trim());

}
}

private void ProcessImport()


{
_tblvnd.Fill(_DsGlrpt.Tbl_vend);
impwire = "Y";
repoheading = "Import Wire Rod Pending Order Status_WithPO";
AddRowsToTblVen(_DsGlrpt.Tbl_vend.Select("IDGRP LIKE 'IM%'"));
}

private void AddRowsToTblVen(IEnumerable<DataRow> dataRows)


{
foreach (DataRow dr in dataRows)
{
DataRow newRow = _DsGlrpt.Tbl_ven.NewRow();
newRow["srno"] = (Int32.Parse(dr["srno"].ToString()) +
cntr).ToString().Trim();
newRow["VENDORID"] = dr["VENDORID"].ToString();
newRow["VENDNAME"] = dr["VENDNAME"].ToString();
newRow["IDGRP"] = dr["IDGRP"].ToString();
newRow["Display_Name"] = dr["SHORTNAME"].ToString().Trim();
newRow["dispseqno"] = 0;
newRow["chk"] = false;
_DsGlrpt.Tbl_ven.Rows.Add(newRow);
cntr++;
}
}

[HttpPost]
[Route("api/rmwirereport/print")]
public IHttpActionResult Print(PrintRequest request)
{
try
{
if (request.Rbtwpo == false && request.Rbtwopo == false)
{
return Json(new { ErrorMessage = "Please select With PO OR
Without PO....." });
}

//_DsGlrpt.DT_ItemSizeMaster.Clear();
//_DsRptdata.Dt_itmgrsz.AcceptChanges();

/*foreach (DataRow dri1 in _DsRptdata.Dt_itmgrsz)


{
if (dri1["SZ"].ToString().Trim() == "0.000" &&
dri1["GR"].ToString().Trim() == "")
{
return Json(new { ErrorMessage = "Size OR Grade can't be
left Blank....." });
}
DataRow dr1 = _DsGlrpt.DT_ItemSizeMaster.NewRow();
dr1["ITEMNO"] = dri1["ITEMNO"].ToString().Trim();
dr1["SIZE"] = decimal.Parse(dri1["SZ"].ToString().Trim());
dr1["GRADE"] = dri1["GR"].ToString().Trim();
dr1["FLAG"] = "1";
_DsGlrpt.DT_ItemSizeMaster.Rows.Add(dr1);
}

if (_DsRptdata.Dt_itmgrsz.Rows.Count > 0)
{
string strinsert =
UpdateData.UpdateACTPPCWireSize("sp_Save_ItemSizeWire", "@UDDT_st_ItemSizeMaster",
_DsGlrpt.DT_ItemSizeMaster, impwire);
}*/

string vndcode = "";


string vdshcd = "";
int cnt = 0;
_DsGlrpt.DT_ImpWPnd.Clear();
foreach (DataRow DRVND in request.Tbl_ven.Select("chk = " + true))
{
cnt++;
}
if (cnt == 0)
{
return Json(new { ErrorMessage = "" });
}

_DsGlrpt.DT_vndshname.Clear();

foreach (DataRow DRVND in request.Tbl_ven.Select("chk = " + true +


"", "Display_Name ASC"))
{
DataRow drvdns = _DsGlrpt.DT_vndshname.NewRow();
vndcode = DRVND["VENDORID"].ToString().Trim();
strvdcode = vndcode;
vdshcd = DRVND["Display_Name"].ToString().Trim();

drvdns["vendshnm"] = vdshcd;

if (request.Minlvl == true) // for Wire Road


{
_wiresz.Fill(_DsRptdata.st_ItemSizeMaster_WIRE, "PW01");

_wroad.Fill(_DsRptdata.Ds_WireRoad, strvdcode);
foreach (DataRow drvn in _DsRptdata.Ds_WireRoad)
{
DataRow DREN1 = _DsGlrpt.DT_ImpWPnd.NewRow();
DREN1["SIZE"] = drvn["SIZE"].ToString().Trim();
DREN1["GRADE"] = drvn["GRADE"].ToString();
DREN1["VDCODE"] = drvn["VDCODE"].ToString();
DREN1["PONUMBER"] = drvn["PONUMBER"].ToString();
DREN1["OQOUTSTAND"] =
Math.Round(decimal.Parse(drvn["OQOUTSTAND"].ToString()) / 1000, 2).ToString();
DREN1["grade1"] = drvn["grade1"].ToString();
DREN1["VDSNM"] = drvn["VDSNM"].ToString();
DREN1["VNDGRID"] =
string.IsNullOrEmpty(drvn["VNDGRID"].ToString()) ? 0 :
Int32.Parse(drvn["VNDGRID"].ToString());
DREN1["grseq"] =
string.IsNullOrEmpty(drvn["grseq"].ToString()) ? 0 :
Int32.Parse(drvn["grseq"].ToString());
_DsGlrpt.DT_ImpWPnd.Rows.Add(DREN1);
}
}

if (request.Qtycom == true) // for Import


{
_impwirepnd.Fill(_DsGlrpt.ImpWirePend, strvdcode);

foreach (DataRow drvn in _DsGlrpt.ImpWirePend)


{
DataRow DREN1 = _DsGlrpt.DT_ImpWPnd.NewRow();
DREN1["SIZE"] = drvn["SIZE"].ToString().Trim();
DREN1["GRADE"] = drvn["GRADE"].ToString();
DREN1["VDCODE"] = drvn["VDCODE"].ToString();
DREN1["PONUMBER"] = drvn["PONUMBER"].ToString();
DREN1["OQOUTSTAND"] =
Math.Round(decimal.Parse(drvn["OQOUTSTAND"].ToString()), 2).ToString();
DREN1["grade1"] = drvn["grade1"].ToString();
DREN1["VDSNM"] = drvn["VDSNM"].ToString();
DREN1["VNDGRID"] =
Int32.Parse(drvn["VNDGRID"].ToString());
DREN1["grseq"] =
string.IsNullOrEmpty(drvn["grseq"].ToString()) ? 0 :
Int32.Parse(drvn["grseq"].ToString());
_DsGlrpt.DT_ImpWPnd.Rows.Add(DREN1);
}
}

if (request.Stkhnd == true) // for Wire


{
_onlywiresz.Fill(_DsRptdata.st_ItemSizeMaster_WIRE1,
"PW02");

_wire.Fill(_DsRptdata.Ds_Wire, strvdcode);

foreach (DataRow drvn in _DsRptdata.Ds_Wire)


{
DataRow DREN1 = _DsGlrpt.DT_ImpWPnd.NewRow();
DREN1["SIZE"] = drvn["SIZE"].ToString().Trim();
DREN1["GRADE"] = drvn["GRADE"].ToString();
DREN1["VDCODE"] = drvn["VDCODE"].ToString();
DREN1["PONUMBER"] = drvn["PONUMBER"].ToString();
DREN1["OQOUTSTAND"] =
Math.Round(decimal.Parse(drvn["OQOUTSTAND"].ToString()) / 1000, 2).ToString();
DREN1["grade1"] = drvn["grade1"].ToString();
DREN1["VDSNM"] = drvn["VDSNM"].ToString();
DREN1["VNDGRID"] =
Int32.Parse(drvn["VNDGRID"].ToString());
DREN1["grseq"] =
string.IsNullOrEmpty(drvn["grseq"].ToString()) ? 0 :
Int32.Parse(drvn["grseq"].ToString());
_DsGlrpt.DT_ImpWPnd.Rows.Add(DREN1);
}
}

_DsGlrpt.DT_vndshname.Rows.Add(drvdns);
}

SqlConnection stsqlcn = new SqlConnection("Data


Source=172.16.1.104;Initial Catalog=ACTPPC;User ID=sa;Password=vikram@apl123");

try
{
string tblcont = "";
string vdsh1 = "";
string vdsh2 = "";
int cntr = 0;
dt.Clear();
dt.Dispose();
dt = new DataTable();

foreach (DataRow DRrtm in _DsGlrpt.DT_vndshname)


{
vdsh1 = DRrtm["vendshnm"].ToString().Trim();
if (vdsh1 != vdsh2)
{
if (request.Strwpo != "Y")
{
if (tblcont == "")
{
tblcont = "RID int,size decimal(5,2), grade
char(10), " + DRrtm["vendshnm"].ToString().Trim() + " decimal(10,2)";
dt.Columns.Add("RID", typeof(int));
dt.Columns.Add("size", typeof(decimal));
dt.Columns.Add("grade", typeof(string));

dt.Columns.Add(DRrtm["vendshnm"].ToString().Trim(), typeof(decimal));
}
if (tblcont != "" && cntr != 0)
{
tblcont = tblcont + "," +
DRrtm["vendshnm"].ToString().Trim() + " decimal(10,2)";

dt.Columns.Add(DRrtm["vendshnm"].ToString().Trim(), typeof(decimal));
}
cntr++;
}

if (request.Strwpo == "Y")
{
if (tblcont == "")
{
tblcont = "RID int,size decimal(5,2), grade
char(10), " + DRrtm["vendshnm"].ToString().Trim() + " decimal(10,2) ," +
DRrtm["vendshnm"].ToString().Trim() + "_PO" + " char(200) ";
dt.Columns.Add("RID", typeof(int));
dt.Columns.Add("size", typeof(decimal));
dt.Columns.Add("grade", typeof(string));

dt.Columns.Add(DRrtm["vendshnm"].ToString().Trim(), typeof(string));

dt.Columns.Add(DRrtm["vendshnm"].ToString().Trim() + "_PO", typeof(string));


}
if (tblcont != "" && cntr != 0)
{
tblcont = tblcont + "," +
DRrtm["vendshnm"].ToString().Trim() + " decimal(10,2)," +
DRrtm["vendshnm"].ToString().Trim() + "_PO" + " char(200) ";

dt.Columns.Add(DRrtm["vendshnm"].ToString().Trim(), typeof(decimal));

dt.Columns.Add(DRrtm["vendshnm"].ToString().Trim() + "_PO", typeof(string));


}
cntr++;
}
}
vdsh2 = vdsh1;
}

stsqlcn.Open();

using (SqlCommand command = new SqlCommand("if exists(select *


from sys.tables where name like 'TEST24MAY_2022%' )" +
"drop table TEST24MAY_2022; CREATE TABLE TEST24MAY_2022("
+ tblcont + "constraint PK_RID primary key clustered(RID) );", stsqlcn))

command.ExecuteNonQuery();
stsqlcn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
stsqlcn.Close();

_DsRptdata.DT_RmRptData.Clear();

if (request.Qtycom == true)
{
GenData_For_Import_Wire();

}
if (request.Minlvl == true) // Wire Rod
{

GenData_WireRod_New_25may2022();
}
if (request.Stkhnd == true)
{
GenData_For_Wire();
}

//@UDDT_RMWIRE_PEND
string status = ClCommon.Create_RmWireRepData("SP_GET_RMWIRE_PEND",
"@UDDT_RMWIRE_PEND", _DsRptdata.DT_RmRptData);
if (isexcelformat == "N")
{
if (status == "DataCreated Successfully")
{
string reptitl = "";

if (request.Qtycom == true) // for IMPORT


{
if (request.Strwpo == "Y")
{

reptitl = "IMPORT Pending Order Status With PO";

//WinCRViewer1 winrep = new


WinCRViewer1("IMPORT_WPND_WPO.rpt", "ACTPPC", reptitl, "", "", "", "", "", "", "",
"", "", "", "", "", "", "");
//winrep.ShowDialog();
}
if (request.Strwpo != "Y")
{
reptitl = "IMPORT Pending Order Status Without PO";
//WinCRViewer1 winrep = new
WinCRViewer1("IMPORT_WPND_nw_ONLYQTY.rpt", "ACTPPC", reptitl, "", "", "", "", "",
"", "", "", "", "", "", "", "", "");
//winrep.ShowDialog();
}

if (request.Minlvl == true) // For Wire Rod


{
if (request.Strwpo == "Y")
{
reptitl = "Wire Rod Pending Order Status With PO";
//WinCRViewer1 winrep = new
WinCRViewer1("RMPND_WIREROD_nw.rpt", "ACTPPC", reptitl, "", "", "", "", "", "", "",
"", "", "", "", "", "", "");
//winrep.ShowDialog();
}
if (request.Strwpo != "Y")
{
reptitl = "Wire Rod Pending Order Status Without
PO";
//WinCRViewer1 winrep = new
WinCRViewer1("RMPND_WIREROD_nw_ONLYQTY.rpt", "ACTPPC", reptitl, "", "", "", "", "",
"", "", "", "", "", "", "", "", "");
//winrep.ShowDialog();
}
}
if (request.Stkhnd == true) // For Wire
{
if (request.Strwpo == "Y")
{
reptitl = "Wire Pending Order Status With PO";
//WinCRViewer1 winrep = new
WinCRViewer1("RMPND_WIREROD_nw.rpt", "ACTPPC", reptitl, "", "", "", "", "", "", "",
"", "", "", "", "", "", "");
//winrep.ShowDialog();
}
if (request.Strwpo != "Y")
{
reptitl = "Wire Pending Order Status Without PO";
//WinCRViewer1 winrep = new
WinCRViewer1("RMPND_WIREROD_nw_ONLYQTY.rpt", "ACTPPC", reptitl, "", "", "", "", "",
"", "", "", "", "", "", "", "", "");
//winrep.ShowDialog();
}

}
else if (status != "DataCreated Successfully")
{
return Json(new { ErrorMessage = "Error : Creating
Data......" });
}
}
return Ok();
}
catch(Exception ex)
{
return Json(new { ErrorMessage = ex.ToString().Trim() /*"Error for
Data Generation....."*/ }) ;
}
}

[HttpPost]
[Route("api/rmwirereport/run")]
public IHttpActionResult Run(PrintRequest request)
{
try
{
int cntr = 1;
string strprevitm = "";
_DsRptdata.Dt_itmgrsz.Clear();
int intchk = 0;

foreach (DataRow DRVND in request.Tbl_ven.Select("chk = " + true))


{
string strvdcode = DRVND["VENDORID"].ToString().Trim();

if (intchk == 0)
{
if (request.Minlvl)
{
_itmnf.Fill(_DsGlrpt.ds_itmsznotfound, "PW01");
}
else if (request.Stkhnd)
{
_itmnf.Fill(_DsGlrpt.ds_itmsznotfound, "PW02");
}
else if (request.Qtycom)
{
_impitmntf.Fill(_DsGlrpt.Import_ItmSzNtFound,
strvdcode);
}
}

if (intchk == 0 && (request.Minlvl || request.Stkhnd))


{
foreach (DataRow dr in _DsGlrpt.ds_itmsznotfound.Rows)
{
DataRow dren1 = _DsRptdata.Dt_itmgrsz.NewRow();
dren1["srn"] = cntr;
dren1["ITEMNO"] = dr["ITEMNO"].ToString().Trim();
dren1["ITEMDESC"] = dr["ITEMDESC"].ToString();
dren1["SZ"] = dr["SZ"].ToString();
dren1["GR"] = dr["GR"].ToString();
_DsRptdata.Dt_itmgrsz.Rows.Add(dren1);
_DsRptdata.Dt_itmgrsz.AcceptChanges();

cntr++;
strprevitm = dr["ITEMNO"].ToString().Trim();
}
}

if (request.Qtycom)
{
foreach (DataRow dr in _DsGlrpt.Import_ItmSzNtFound.Rows)
{
DataRow dren1 = _DsRptdata.Dt_itmgrsz.NewRow();
dren1["srn"] = cntr;
dren1["ITEMNO"] = dr["ITEMNO"].ToString().Trim();
dren1["ITEMDESC"] = dr["ITEMDESC"].ToString();
dren1["SZ"] = dr["SZ"].ToString();
dren1["GR"] = dr["GR"].ToString();
_DsRptdata.Dt_itmgrsz.Rows.Add(dren1);
cntr++;
}
}
intchk++;
}

if (_DsRptdata.Dt_itmgrsz.Rows.Count > 0)
{
return Json(_DsRptdata.Dt_itmgrsz);
}
else
{
return Json("All Record Found Ok .....");
}
}
catch (Exception ex)
{
return Json($"Error Item Data: {ex.Message}");
}
}

public class PrintRequest


{
public bool Minlvl { get; set; }
public bool Qtycom { get; set; }
public bool Stkhnd { get; set; }
public bool Rbtwpo { get; set; }
public bool Rbtwopo { get; set; }
public string Strwpo { get; set; }
public DataTable Tbl_ven { get; set; }
}

private void GenData_For_Import_Wire()


{
int pkey = 1;
foreach (DataRow drgrd in _DsRptdata.Ds_Grade)
{
string vdg = drgrd["gr"].ToString().Trim();

DataRow[] drvgr = _DsGlrpt.DT_ImpWPnd.Select("grade1 = '" + vdg +


"'", "SIZE, grseq,VNDGRID asc");
if (drvgr.Length > 0)
{

foreach (DataRow DR in _DsRptdata.st_ItemSizeMaster)// for


getting size
{
string sz = DR["SIZE"].ToString().Trim().Substring(0, 5);

DataRow DREN11 = dt.NewRow();


DREN11["RID"] = pkey;
DREN11["size"] = decimal.Parse(sz.ToString().Trim());
DREN11["grade"] = vdg;
dt.Rows.Add(DREN11);

foreach (DataRow DRsn in _DsGlrpt.DT_vndshname)


{
string strvdshnm = DRsn["vendshnm"].ToString().Trim();
DataRow[] drv = _DsGlrpt.DT_ImpWPnd.Select("SIZE ='" +
sz + "' and grade1 = '" + vdg + "' and VDSNM = '" + strvdshnm + "'", "SIZE,
grseq,VDSNM asc"); // atul k 25-may-2022

int ctrl = 0;
foreach (DataRow DR1 in drv)
{
if (DR1["VDSNM"].ToString().Trim() ==
DRsn["vendshnm"].ToString().Trim())
{
string fldnm =
DRsn["vendshnm"].ToString().Trim();
string fldnm1 =
DRsn["vendshnm"].ToString().Trim() + "_PO";

if (strwpo != "Y")
{
if (ctrl == 0)
DREN11[fldnm] =
DR1["OQOUTSTAND"].ToString();
if (ctrl > 0)
DREN11[fldnm] =
decimal.Parse(DREN11[fldnm].ToString().Trim()) +
decimal.Parse(DR1["OQOUTSTAND"].ToString().Trim());
}

if (strwpo == "Y")
{
if (ctrl == 0)
{
DREN11[fldnm] =
DR1["OQOUTSTAND"].ToString();
DREN11[fldnm1] =
DR1["OQOUTSTAND"].ToString() + "," + "(" + DR1["PONUMBER"].ToString().Trim() + ")";
}

if (ctrl > 0)
{
DREN11[fldnm] =
decimal.Parse(DREN11[fldnm].ToString().Trim()) +
decimal.Parse(DR1["OQOUTSTAND"].ToString().Trim());
DREN11[fldnm1] =
DREN11[fldnm1].ToString().Trim() + "," + DR1["OQOUTSTAND"].ToString() + "," + "(" +
DR1["PONUMBER"].ToString().Trim() + ")";

}
}

}
ctrl++;
}
//
}
pkey++;

}
}

// BELOW CODE FOR EXPORT DATA TABLE DIRECTLY TO EXCEL

//App_Code.ExcelUtlity obj = new App_Code.ExcelUtlity();


//obj.WriteDataTableToExcel(dt, "WireRod Pending Report", "c:\\Joshi\\
WireRod.xlsx", "WithPO");

MessageBox.Show("Excel created c:\\Joshi\\WireRod.xlsx");

SqlConnection con = new SqlConnection("Data Source=172.16.1.104;Initial


Catalog=ACTPPC;User ID=sa;Password=vikram@apl123");
SqlBulkCopy objbulk = new SqlBulkCopy(con);
//assign Destination table name
objbulk.DestinationTableName = "TEST24MAY_2022";
con.Open();
//insert bulk Records into DataBase.
objbulk.WriteToServer(dt);
con.Close();
}

private void GenData_WireRod_New_25may2022()


{
int pkey = 1;
foreach (DataRow drgrd in _DsRptdata.DS_WIRE_GRADE)
{
string vdg = drgrd["gr"].ToString().Trim();

DataRow[] drvgr = _DsGlrpt.DT_ImpWPnd.Select("grade1 = '" + vdg +


"'", "SIZE, grseq,VNDGRID asc");
if (drvgr.Length > 0)
{

foreach (DataRow DR in
_DsRptdata.st_ItemSizeMaster_WIRE)//st_ItemSizeMaster
{

string sz = DR["SIZE"].ToString().Trim();

DataRow DREN11 = dt.NewRow();


DREN11["RID"] = pkey;
DREN11["size"] = decimal.Parse(sz.ToString().Trim());
DREN11["grade"] = vdg;// Atul K 18-Nov-2020
dt.Rows.Add(DREN11);

foreach (DataRow DRsn in _DsGlrpt.DT_vndshname)


{
string strvdshnm = DRsn["vendshnm"].ToString().Trim();
DataRow[] drv = _DsGlrpt.DT_ImpWPnd.Select("SIZE ='" +
sz + "' and grade1 = '" + vdg + "' and VDSNM = '" + strvdshnm + "'", "SIZE,
grseq,VDSNM asc"); // atul k 25-may-2022

int ctrl = 0;
foreach (DataRow DR1 in drv)
{
if (DR1["VDSNM"].ToString().Trim() ==
DRsn["vendshnm"].ToString().Trim())
{
string fldnm =
DRsn["vendshnm"].ToString().Trim();
string fldnm1 =
DRsn["vendshnm"].ToString().Trim() + "_PO";

if (strwpo != "Y")
{
if (ctrl == 0)
DREN11[fldnm] =
DR1["OQOUTSTAND"].ToString();
if (ctrl > 0)
DREN11[fldnm] =
decimal.Parse(DREN11[fldnm].ToString().Trim()) +
decimal.Parse(DR1["OQOUTSTAND"].ToString().Trim());
}

if (strwpo == "Y")
{
if (ctrl == 0)
{
DREN11[fldnm] =
DR1["OQOUTSTAND"].ToString();
DREN11[fldnm1] =
DR1["OQOUTSTAND"].ToString() + "," + "(" + DR1["PONUMBER"].ToString().Trim() + ")";
}

if (ctrl > 0)
{
DREN11[fldnm] =
decimal.Parse(DREN11[fldnm].ToString().Trim()) +
decimal.Parse(DR1["OQOUTSTAND"].ToString().Trim());
DREN11[fldnm1] =
DREN11[fldnm1].ToString().Trim() + "," + DR1["OQOUTSTAND"].ToString() + "," + "(" +
DR1["PONUMBER"].ToString().Trim() + ")";

}
}

}
ctrl++;
}

}
pkey++;

}
}
}

//App_Code.ExcelUtlity obj = new App_Code.ExcelUtlity();

//obj.WriteDataTableToExcel(dt, "WireRod Pending Report", "c:\\Joshi\\


WireRod.xlsx", "WithPO");

MessageBox.Show("Excel created c:\\Joshi\\WireRod.xlsx");

SqlConnection con = new SqlConnection("Data Source=172.16.1.104;Initial


Catalog=ACTPPC;User ID=sa;Password=vikram@apl123");
SqlBulkCopy objbulk = new SqlBulkCopy(con);
//assign Destination table name
objbulk.DestinationTableName = "TEST24MAY_2022";
con.Open();
//insert bulk Records into DataBase.
objbulk.WriteToServer(dt);
con.Close();

}
private void GenData_For_Wire()
{
int pkey = 1;
foreach (DataRow drgrd in _DsRptdata.DS_WIRE_GRADE)
{
string vdg = drgrd["gr"].ToString().Trim();

DataRow[] drvgr = _DsGlrpt.DT_ImpWPnd.Select("grade1 = '" + vdg +


"'", "SIZE, grseq,VNDGRID asc");
if (drvgr.Length > 0)
{

foreach (DataRow DR in _DsRptdata.st_ItemSizeMaster_WIRE1)//


for getting size
{
string sz = DR["SIZE"].ToString().Trim().Substring(0, 5);

DataRow DREN11 = dt.NewRow();


DREN11["RID"] = pkey;
DREN11["size"] = decimal.Parse(sz.ToString().Trim());
DREN11["grade"] = vdg;
dt.Rows.Add(DREN11);

foreach (DataRow DRsn in _DsGlrpt.DT_vndshname)


{
string strvdshnm = DRsn["vendshnm"].ToString().Trim();
DataRow[] drv = _DsGlrpt.DT_ImpWPnd.Select("SIZE ='" +
sz + "' and grade1 = '" + vdg + "' and VDSNM = '" + strvdshnm + "'", "SIZE,
grseq,VDSNM asc"); // atul k 25-may-2022

int ctrl = 0;
foreach (DataRow DR1 in drv)
{
if (DR1["VDSNM"].ToString().Trim() ==
DRsn["vendshnm"].ToString().Trim())
{
string fldnm =
DRsn["vendshnm"].ToString().Trim();
string fldnm1 =
DRsn["vendshnm"].ToString().Trim() + "_PO";

if (strwpo != "Y")
{
if (ctrl == 0)
DREN11[fldnm] =
DR1["OQOUTSTAND"].ToString();
if (ctrl > 0)
DREN11[fldnm] =
decimal.Parse(DREN11[fldnm].ToString().Trim()) +
decimal.Parse(DR1["OQOUTSTAND"].ToString().Trim());
}

if (strwpo == "Y")
{
if (ctrl == 0)
{
DREN11[fldnm] =
DR1["OQOUTSTAND"].ToString();
DREN11[fldnm1] =
DR1["OQOUTSTAND"].ToString() + "," + "(" + DR1["PONUMBER"].ToString().Trim() + ")";
}

if (ctrl > 0)
{
DREN11[fldnm] =
decimal.Parse(DREN11[fldnm].ToString().Trim()) +
decimal.Parse(DR1["OQOUTSTAND"].ToString().Trim());
DREN11[fldnm1] =
DREN11[fldnm1].ToString().Trim() + "," + DR1["OQOUTSTAND"].ToString() + "," + "(" +
DR1["PONUMBER"].ToString().Trim() + ")";

}
}

}
ctrl++;
}
}
pkey++;

}
}

// BELOW CODE FOR EXPORT DATA TABLE DIRECTLY TO EXCEL

//App_Code.ExcelUtlity obj = new App_Code.ExcelUtlity();

//obj.WriteDataTableToExcel(dt, "WireRod Pending Report", "c:\\Joshi\\


WireRod.xlsx", "WithPO");

MessageBox.Show("Excel created c:\\Joshi\\WireRod.xlsx");

SqlConnection con = new SqlConnection("Data Source=172.16.1.104;Initial


Catalog=ACTPPC;User ID=sa;Password=vikram@apl123");
SqlBulkCopy objbulk = new SqlBulkCopy(con);
//assign Destination table name
objbulk.DestinationTableName = "TEST24MAY_2022";
con.Open();
//insert bulk Records into DataBase.
objbulk.WriteToServer(dt);
con.Close();

}
}
public class rmwirpt
{
public string name { get; set; }
public bool value { get; set; }
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy