private void Insert_Click(object sender, EventArgs e) { // assign connection values and create variables to use string hostName = "den-vm-dg02"; // replace with your host or leverage a config file or similar approach int hostPort = 9000; string userName = "******"; string userPassword = ""; Boolean x = false; string subroutine = ""; int args = 0; String Account = "acme"; //Prepare to call the subroutine that gets writes the new customer Pick D3 = new rocketsoftware.MVSP.Pick(); // make an instance of the D3 class Functions func = new Functions(); // make an instance of the Functions Class x = D3.Connect(hostName, hostPort, userName, userPassword); // connect to D3 and check status if (x) { bool acctstat = D3.Logto(Account, ""); //Move to the correct account if (acctstat) { subroutine = "WriteCustItem.sub"; args = 8; Pick.mvSubroutine mysub = new Pick.mvSubroutine(subroutine, args, D3); this.dataGridView1.ReadOnly = true; // MAKE SURE WE RETURN THE GRID TO READ ONLY int Itemrow = dataGridView1.RowCount - 1; // Make sure we are on the new insert row // set the required arguments into the array for the arguments of the subroutine mysub.SetArgs(0, dataGridView1.Rows[Itemrow].Cells[0].Value.ToString()); //get CustomerID mysub.SetArgs(1, dataGridView1.Rows[Itemrow].Cells[1].Value.ToString()); //get Customer Name mysub.SetArgs(2, dataGridView1.Rows[Itemrow].Cells[2].Value.ToString()); //get Customer Address mysub.SetArgs(3, dataGridView1.Rows[Itemrow].Cells[3].Value.ToString()); //get Customer City mysub.SetArgs(4, dataGridView1.Rows[Itemrow].Cells[4].Value.ToString()); //get Customer State mysub.SetArgs(5, dataGridView1.Rows[Itemrow].Cells[5].Value.ToString()); //get Customer Zip mysub.SetArgs(6, dataGridView1.Rows[Itemrow].Cells[6].Value.ToString()); //get Customer Phone mysub.MvCall(); string Status = mysub.GetArgs(7); // gets the return values from the subroutine Add_Row.Visible = true; // swap the displayed buttons Insert.Visible = false; D3.CloseConnection(); //close out the connection to D3 } else { MessageBox.Show(Account + ": Not Found", "Invalid Account", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Environment.Exit(0); } } else { MessageBox.Show("Unable to connect to D3", "Connection Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Environment.Exit(0); } }
private void ContextStrip_Click(object sender, EventArgs e) { if (!this.dataGridView1.Rows[this.rowIndex].IsNewRow) { // assign connection values and create variables to use string hostName = "den-vm-dg02"; // replace with your host or leverage a config file or similar approach int hostPort = 9000; string userName = "******"; string userPassword = ""; Boolean x = false; string subroutine = ""; int args = 0; String Account = "acme"; //Prepare to call the subroutine that deletes customer string ItemID = dataGridView1.Rows[this.rowIndex].Cells[0].Value.ToString(); //get CustomerID this.dataGridView1.Rows.RemoveAt(this.rowIndex); Pick D3 = new rocketsoftware.MVSP.Pick(); // make an instance of the D3 class Functions func = new Functions(); // make an instance of the Functions Class x = D3.Connect(hostName, hostPort, userName, userPassword); // connect to D3 and check status if (x) { bool acctstat = D3.Logto(Account, ""); //Move to the correct account if (acctstat) { subroutine = "delete_cust_item.sub"; args = 2; Pick.mvSubroutine mysub = new Pick.mvSubroutine(subroutine, args, D3); mysub.SetArgs(0, ItemID); mysub.MvCall(); string Status = mysub.GetArgs(1); // gets the return values from the subroutine Add_Row.Visible = true; // swap the displayed buttons Insert.Visible = false; D3.CloseConnection(); //close out the connection to D3 } } else { MessageBox.Show(Account + ": Not Found", "Invalid Account", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Environment.Exit(0); } } else { MessageBox.Show("Unable to connect to D3", "Connection Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Environment.Exit(0); } }
protected void Grid_CustList_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteItem") { // Retrieve the row index stored in the // CommandArgument property. int row_index = int.Parse(e.CommandArgument.ToString()); string CUSTID = ((HyperLink)Grid_CustList.Rows[row_index].Cells[0].FindControl("HyperLink1")).Text; // assign connection values and create variables to use string hostName = "den-vm-dg02"; // replace with your host or leverage a config file or similar approach int hostPort = 9000; string userName = "******"; string userPassword = ""; Boolean x = false; string subroutine = ""; int args = 0; String Account = "acme"; Pick D3 = new rocketsoftware.MVSP.Pick(); // make an instance of the D3 class Functions func = new Functions(); // make an instance of the Functions Class x = D3.Connect(hostName, hostPort, userName, userPassword); // connect to D3 and check status if (x) { bool acctstat = D3.Logto(Account, ""); //Move to the correct account if (acctstat) { subroutine = "delete_cust_item.sub"; args = 2; Pick.mvSubroutine mysub = new Pick.mvSubroutine(subroutine, args, D3); mysub.SetArgs(0, CUSTID); mysub.MvCall(); string Status = mysub.GetArgs(1); // gets the return values from the subroutine // do proper error handling on return status Grid_CustList.DataBind(); D3.CloseConnection(); //close out the connection to D3 Response.Redirect(Request.RawUrl); } } } }
protected void Page_Load(object sender, EventArgs e) { var vm = (char)253; var svm = (char)252; string hostName = "den-vm-dg02"; // replace with your host or leverage a config file or similar approach int hostPort = 9000; string userName = "******"; string userPassword = ""; Boolean x = false; string Account = "acme"; string subroutine = "get_invoice.sub"; int args = 0; string InvoiceSelection = Request.QueryString["param"]; Pick D3 = new rocketsoftware.MVSP.Pick(); Functions func = new Functions(); x = D3.Connect(hostName, hostPort, userName, userPassword); if (x) { bool acctstat = D3.Logto(Account, ""); //Move to the correct account if (acctstat) { args = 2; Pick.mvSubroutine mysub = new Pick.mvSubroutine(subroutine, args, D3); mysub.SetArgs(0, InvoiceSelection); mysub.SetArgs(1, ""); mysub.MvCall(); // call get_invoice.sub string InvoiceResult = mysub.GetArgs(1); tbl_AccountID.Text = func.Extract(InvoiceResult, 1); tbl_BillTo.Text = func.Extract(InvoiceResult, 2); tbl_BillToAddr.Text = func.Extract(InvoiceResult, 3); var BillCity = func.Extract(InvoiceResult, 4); var BillState = func.Extract(InvoiceResult, 5); var BillZip = func.Extract(InvoiceResult, 6); tbl_BillToCSZ.Text = BillCity + ", " + BillState + " " + BillZip; tbl_Contact.Text = func.Extract(InvoiceResult, 7); tbl_InvoiceID.Text = func.Extract(InvoiceResult, 8); tbl_ShipTo.Text = func.Extract(InvoiceResult, 9); tbl_ShipToAddr.Text = func.Extract(InvoiceResult, 10); var ShipCity = func.Extract(InvoiceResult, 11); var ShipState = func.Extract(InvoiceResult, 12); var ShipZip = func.Extract(InvoiceResult, 13); tbl_ShipToCSZ.Text = ShipCity + ", " + ShipState + " " + ShipZip; tbl_SalesRep.Text = func.Extract(InvoiceResult, 15, 1); tbl_RepPhone.Text = func.Extract(InvoiceResult, 16, 2); tbl_Ordered.Text = func.Extract(InvoiceResult, 17); tbl_Invoiced.Text = func.Extract(InvoiceResult, 18); tbl_Terms.Text = func.Extract(InvoiceResult, 19); tbl_Note.Text = func.Extract(InvoiceResult, 20); tbl_Gross.Text = func.Extract(InvoiceResult, 21); tbl_Discount.Text = func.Extract(InvoiceResult, 22); tbl_Net.Text = func.Extract(InvoiceResult, 23); //declare the strings needed to do the deletes of the mv attributes that are not part of the line items so we can get an accurate count string LineResults1 = ""; string LineResults2 = ""; int mvLineCount = 7; LineResults1 = func.Delete(InvoiceResult, 15); LineResults2 = func.Delete(LineResults1, 15); int vmCount = func.Dcount(LineResults2, vm); int svmCount = func.Count(LineResults2, svm); // find out how many actual line items we have int itemCount = vmCount / mvLineCount; //Create dataTable DataTable dt = new DataTable(); //map results into a dataTable that can be then bound to the dataGrid // Create the Headers for the DataTable that needs to mapped so that the DataGrid can bind to it. dt.Columns.Add("Ln", typeof(string)); dt.Columns.Add("Qty", typeof(string)); dt.Columns.Add("ItemId", typeof(string)); dt.Columns.Add("Description", typeof(string)); dt.Columns.Add("UnitPrice", typeof(string)); dt.Columns.Add("ExtPrice", typeof(Int32)); dt.Columns.Add("Disc", typeof(string)); dt.Columns.Add("Ext", typeof(Int32)); //Get Each Line Item for (int i = 0; i <= itemCount; i++) { dt.Rows.Add(); dt.Rows[dt.Rows.Count - 1]["Ln"] = i + 1; // LineQty dt.Rows[dt.Rows.Count - 1]["Qty"] = func.Extract(InvoiceResult, 24, i + 1); // Line Qty dt.Rows[dt.Rows.Count - 1]["ItemId"] = func.Extract(InvoiceResult, 25, i + 1); // Product Number dt.Rows[dt.Rows.Count - 1]["Description"] = func.Extract(InvoiceResult, 26, i + 1); // Description dt.Rows[dt.Rows.Count - 1]["UnitPrice"] = decimal.Parse(func.Extract(InvoiceResult, 27, i + 1)); // List or Unit Price dt.Rows[dt.Rows.Count - 1]["ExtPrice"] = decimal.Parse(func.Extract(InvoiceResult, 28, i + 1)); // Total Gross dt.Rows[dt.Rows.Count - 1]["Disc"] = func.Extract(InvoiceResult, 29, i + 1); // Total Discount is a % dt.Rows[dt.Rows.Count - 1]["Ext"] = decimal.Parse(func.Extract(InvoiceResult, 31, i + 1)); // Total Net } Grid_InvoiceList.DataSource = dt; Grid_InvoiceList.DataBind(); D3.CloseConnection(); } } }
public Invoice() { InitializeComponent(); StartPosition = FormStartPosition.CenterScreen; //center form this.FormClosing += Invoice_FormClosing; // set close event var vm = (char)253; var svm = (char)252; string hostName = "den-vm-dg02"; // replace with your host or leverage a config file or similar approach int hostPort = 9000; string userName = "******"; string userPassword = ""; Boolean x = false; string Account = "acme"; string subroutine = "get_invoice.sub"; int args = 0; string InvoiceSelection = formargs.InvoiceSelection; Pick D3 = new rocketsoftware.MVSP.Pick(); Functions func = new Functions(); x = D3.Connect(hostName, hostPort, userName, userPassword); if (x) { bool acctstat = D3.Logto(Account, ""); //Move to the correct account if (acctstat) { args = 2; Pick.mvSubroutine mysub = new Pick.mvSubroutine(subroutine, args, D3); mysub.SetArgs(0, InvoiceSelection); mysub.SetArgs(1, ""); mysub.MvCall(); // call get_invoice.sub if (D3.statusCode != 0) { MessageBox.Show("Unable to execute:" + D3.ruleModule, "Subroutine Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Environment.Exit(0); } else { string InvoiceResult = mysub.GetArgs(1); AccountNo.Text = func.Extract(InvoiceResult, 1); BillTo.Text = func.Extract(InvoiceResult, 2); BillAddr.Text = func.Extract(InvoiceResult, 3); var BillCity = func.Extract(InvoiceResult, 4); var BillState = func.Extract(InvoiceResult, 5); var BillZip = func.Extract(InvoiceResult, 6); Bill_CityStateZip.Text = BillCity + ", " + BillState + " " + BillZip; Contact.Text = func.Extract(InvoiceResult, 7); InvoiceNo.Text = func.Extract(InvoiceResult, 8); ShipTo.Text = func.Extract(InvoiceResult, 9); ShipAddr.Text = func.Extract(InvoiceResult, 10); var ShipCity = func.Extract(InvoiceResult, 11); var ShipState = func.Extract(InvoiceResult, 12); var ShipZip = func.Extract(InvoiceResult, 13); Ship_CityStateZip.Text = ShipCity + ", " + ShipState + " " + ShipZip; SalesRep.Text = func.Extract(InvoiceResult, 15,1); RepPhone.Text = func.Extract(InvoiceResult, 16,2); Ordered.Text = func.Extract(InvoiceResult, 17); Invoiced.Text = func.Extract(InvoiceResult, 18); Terms.Text = func.Extract(InvoiceResult, 19); Note.Text = func.Extract(InvoiceResult, 20); Gross.Text = func.Extract(InvoiceResult, 21); Discount.Text = func.Extract(InvoiceResult, 22); Net.Text = func.Extract(InvoiceResult, 23); //declare the strings needed to do the deletes of the mv attributes that are not part of the line items so we can get an accurate count string LineResults1 = ""; string LineResults2 = ""; int mvLineCount = 7; LineResults1 = func.Delete(InvoiceResult, 15); LineResults2 = func.Delete(LineResults1, 15); int vmCount = func.Dcount(LineResults2, vm); int svmCount = func.Count(LineResults2, svm); // find out how many actual line items we have int itemCount = vmCount / mvLineCount; //Get Each Line Item for(int i = 0; i <= itemCount; i++) { dataGridView1.Rows.Add(); dataGridView1.Rows[i].Cells[0].Value = i + 1; // LineQty dataGridView1.Rows[i].Cells[1].Value = func.Extract(InvoiceResult, 24, i + 1); // Line Qty dataGridView1.Rows[i].Cells[2].Value = func.Extract(InvoiceResult, 25, i + 1); // Product Number dataGridView1.Rows[i].Cells[3].Value = func.Extract(InvoiceResult, 26, i + 1); // Description dataGridView1.Rows[i].Cells[4].Value = decimal.Parse(func.Extract(InvoiceResult, 27, i + 1)); // List or Unit Price dataGridView1.Rows[i].Cells[5].Value = decimal.Parse(func.Extract(InvoiceResult, 28, i + 1)); // Total Gross dataGridView1.Rows[i].Cells[6].Value = func.Extract(InvoiceResult, 29, i + 1); // Total Discount is a % dataGridView1.Rows[i].Cells[7].Value = decimal.Parse(func.Extract(InvoiceResult, 31, i + 1)); // Total Net } } } } }
public CustList() { InitializeComponent(); StartPosition = FormStartPosition.CenterScreen; //center form this.FormClosing += CustList_FormClosing; // retrieve search arguments from previous customer search form string custName = formargs.Selection[0]; string custAddress = formargs.Selection[1]; string custPhone = formargs.Selection[2]; string custTerrNo = formargs.Selection[3]; var am = (char)254; var vm = (char)253; // assign connection values and create variables to use string hostName = "den-vm-dg02"; // replace with your host or leverage a config file or similar approach int hostPort = 9000; string userName = "******"; string userPassword = ""; Boolean x = false; string subroutine = ""; int args = 0; String Account = "acme"; Pick D3 = new rocketsoftware.MVSP.Pick(); // make an instance of the D3 class Functions func = new Functions(); // make an instance of the Functions Class x = D3.Connect(hostName, hostPort, userName, userPassword); // connect to D3 and check status if (x) { bool acctstat = D3.Logto(Account, ""); //Move to the correct account if (acctstat) { //Prepare to call the subroutine that gets the customer lists subroutine = "cust_lookup.sub"; args = 5; Pick.mvSubroutine mysub = new Pick.mvSubroutine(subroutine, args, D3); mysub.SetArgs(0, custName); // set the required arguments into the array for the arguments of the subroutine mysub.SetArgs(1, custAddress); mysub.SetArgs(2, custPhone); mysub.SetArgs(3, custTerrNo); mysub.SetArgs(4, ""); mysub.MvCall(); string custResults = mysub.GetArgs(4); // gets the return values from the subroutine int amCount = func.Count(custResults, am); // counts the number of items we have int vmCount = func.Dcount(custResults, vm); int itemCount = vmCount / amCount; //determine how many items we retreived for (int v = 0; v < itemCount; v++) // need to add 1 to the amCount to allow for the loop going enogh times for all items { dataGridView1.Rows.Add(); // add row so we can insert into // map results into the form's datagrid dataGridView1.Rows[v].Cells[0].Value = func.Extract(custResults, 1, v + 1); //AccountNo dataGridView1.Rows[v].Cells[1].Value = func.Extract(custResults, 2, v + 1); //Customer Name dataGridView1.Rows[v].Cells[2].Value = func.Extract(custResults, 3, v + 1); //Address dataGridView1.Rows[v].Cells[3].Value = func.Extract(custResults, 4, v + 1); //City dataGridView1.Rows[v].Cells[4].Value = func.Extract(custResults, 5, v + 1); //State dataGridView1.Rows[v].Cells[5].Value = func.Extract(custResults, 6, v + 1); // Zip dataGridView1.Rows[v].Cells[6].Value = func.Extract(custResults, 7, v + 1); // Phone } D3.CloseConnection(); //close out the connection to D3 } else { MessageBox.Show(Account + ": Not Found", "Invalid Account", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Environment.Exit(0); } } else { MessageBox.Show("Unable to connect to D3", "Connection Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Environment.Exit(0); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // retrieve search arguments from previous customer search form string custName = (string)(Session["CustName"]); string custAddress = (string)(Session["CustAddr"]); string custPhone = (string)(Session["CustPhone"]); string custTerrNo = (string)(Session["CustTerr"]); var am = (char)254; var vm = (char)253; // assign connection values and create variables to use string hostName = "den-vm-dg02"; // replace with your host or leverage a config file or similar approach int hostPort = 9000; string userName = "******"; string userPassword = ""; Boolean x = false; string subroutine = ""; int args = 0; String Account = "acme"; Pick D3 = new rocketsoftware.MVSP.Pick(); // make an instance of the D3 class Functions func = new Functions(); // make an instance of the Functions Class x = D3.Connect(hostName, hostPort, userName, userPassword); // connect to D3 and check status if (x) { bool acctstat = D3.Logto(Account, ""); //Move to the correct account //if (acctstat) // { //Prepare to call the subroutine that gets the customer lists subroutine = "cust_lookup.sub"; args = 5; Pick.mvSubroutine mysub = new Pick.mvSubroutine(subroutine, args, D3); mysub.SetArgs(0, custName); // set the required arguments into the array for the arguments of the subroutine mysub.SetArgs(1, custAddress); mysub.SetArgs(2, custPhone); mysub.SetArgs(3, custTerrNo); mysub.SetArgs(4, ""); mysub.MvCall(); string custResults = mysub.GetArgs(4); // gets the return values from the subroutine int amCount = func.Count(custResults, am); // counts the number of items we have if (amCount != 0) { int vmCount = func.Dcount(custResults, vm); int itemCount = vmCount / amCount; //determine how many items we retreived DataTable dt = new DataTable(); //map results into a dataTable that can be then bound to the dataGrid // Create the Headers for the DataTable dt.Columns.Add("Account#", typeof(string)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Address", typeof(string)); dt.Columns.Add("City", typeof(string)); dt.Columns.Add("State", typeof(string)); dt.Columns.Add("Zip", typeof(string)); dt.Columns.Add("Phone", typeof(string)); for (int v = 0; v < itemCount + 1; v++) // need to add 1 to the amCount to allow for the loop going enough times for all items { dt.Rows.Add(); dt.Rows[dt.Rows.Count - 1]["Account#"] = func.Extract(custResults, 1, v + 1); dt.Rows[dt.Rows.Count - 1]["Name"] = func.Extract(custResults, 2, v + 1); dt.Rows[dt.Rows.Count - 1]["Address"] = func.Extract(custResults, 3, v + 1); dt.Rows[dt.Rows.Count - 1]["City"] = func.Extract(custResults, 4, v + 1); dt.Rows[dt.Rows.Count - 1]["State"] = func.Extract(custResults, 5, v + 1); dt.Rows[dt.Rows.Count - 1]["Zip"] = func.Extract(custResults, 6, v + 1); dt.Rows[dt.Rows.Count - 1]["Phone"] = func.Extract(custResults, 7, v + 1); } Grid_CustList.DataSource = dt; Grid_CustList.DataBind(); Session["dt_table"] = dt; } else { lbl_STATUS.Text = custResults; btn_NewSearch.Visible = false; } // show error and hide controls D3.CloseConnection(); //close out the connection to D3 } } }
protected void Page_Load(object sender, EventArgs e) { string hostName = "den-vm-dg02"; // replace with your host. Rather than hardcode you would want to leverage a config file or similar approach int hostPort = 9000; string userName = "******"; string userPassword = ""; Boolean x = false; string fileName = "customers"; string invoiceID = ""; string salesrep = ""; int args = 0; string subroutine = ""; String AcctSelection = Request.QueryString["param"]; Pick D3 = new rocketsoftware.MVSP.Pick(); Functions func = new Functions(); x = D3.Connect(hostName, hostPort, userName, userPassword); bool acctstat = D3.Logto("acme", ""); // log over to the appropriate account String CustomerName = D3.FileReadv(fileName, AcctSelection, 1); // read the customer file to get the customer name lbl_CustomeName.Text = CustomerName; // assign the customer name to the custmer name display // Create DataTable DataTable dt = new DataTable(); //map results into a dataTable that can be then bound to the dataGrid // Create the Headers for the DataTable that needs to mapped so that the DataGrid can bind to it. dt.Columns.Add("Invoice#", typeof(string)); dt.Columns.Add("InvoiceDate", typeof(string)); dt.Columns.Add("OrderDate", typeof(string)); dt.Columns.Add("Terms", typeof(string)); dt.Columns.Add("Gross", typeof(Int32)); dt.Columns.Add("Discount", typeof(Int32)); dt.Columns.Add("NetInvoice", typeof(Int32)); // build the query to get the Invoice IDs that meet the selection criteria D3.ExecuteQuery("Query", "TRX.MST", "With cust.acct# = " + "" + AcctSelection + "" + " and with invoice.date", "by-dsnd invoice.date", " trx#", ""); int rowcount = D3.MVResultSetGetRowCount(); for (int i = 0; i < rowcount; i++) // loop through the ID list to read each matching Item { D3.MVResultSetNext(); invoiceID = D3.MVResultSetGetCurrentRow(); // gets the invoiceID from the result set to use for the subsequent readfile statements fileName = "TRX.MST"; string trxItem = D3.FileRead(fileName, invoiceID); string invoiceDate = func.Extract(trxItem, 21); args = 2; subroutine = "date_convert.sub"; Pick.mvSubroutine mysub = new Pick.mvSubroutine(subroutine, args, D3); mysub.SetArgs(0, invoiceDate); mysub.SetArgs(1, ""); mysub.MvCall(); // call date conversion invoiceDate = mysub.GetArgs(1); string orderDate = func.Extract(trxItem, 18); mysub.SetArgs(0, orderDate); mysub.MvCall(); // call date conversion orderDate = mysub.GetArgs(1); // convert to int to do math int TotalGross = Convert.ToInt32(func.Extract(trxItem, 31)); int TotalDiscount = Convert.ToInt32(func.Extract(trxItem, 32)); int TotalNet = (TotalGross - TotalDiscount); string Comments = func.Extract(trxItem, 23); string TerrID = func.Extract(trxItem, 8); fileName = "territories"; string Terr_Results = D3.FileRead(fileName, TerrID); if (D3.statusCode != 0) { salesrep = ""; } // no sales rep for the territory else { string territory = func.Extract(Terr_Results, 2); fileName = "salesreps"; salesrep = D3.FileReadv(fileName, territory, 1); } dt.Rows.Add(); dt.Rows[dt.Rows.Count - 1]["Invoice#"] = invoiceID; dt.Rows[dt.Rows.Count - 1]["InvoiceDate"] = invoiceDate; dt.Rows[dt.Rows.Count - 1]["OrderDate"] = orderDate; dt.Rows[dt.Rows.Count - 1]["Terms"] = "Net 30"; // no terms in database dt.Rows[dt.Rows.Count - 1]["Gross"] = TotalGross; dt.Rows[dt.Rows.Count - 1]["Discount"] = TotalDiscount; dt.Rows[dt.Rows.Count - 1]["NetInvoice"] = TotalNet; } Grid_Invoices.DataSource = dt; Grid_Invoices.DataBind(); D3.CloseConnection(); }
private void ContextStrip_Click(object sender, EventArgs e) { if (!this.dataGridView1.Rows[this.rowIndex].IsNewRow) { // assign connection values and create variables to use string hostName = "den-vm-dg02"; // replace with your host or leverage a config file or similar approach int hostPort = 9000; string userName = "******"; string userPassword = ""; Boolean x = false; string subroutine = ""; int args = 0; String Account = "acme"; //Prepare to call the subroutine that deletes customer string ItemID = dataGridView1.Rows[this.rowIndex].Cells[0].Value.ToString(); //get CustomerID this.dataGridView1.Rows.RemoveAt(this.rowIndex); Pick D3 = new rocketsoftware.MVSP.Pick(); // make an instance of the D3 class Functions func = new Functions(); // make an instance of the Functions Class x = D3.Connect(hostName, hostPort, userName, userPassword); // connect to D3 and check status if (x) { bool acctstat = D3.Logto(Account, ""); //Move to the correct account if (acctstat) { subroutine = "delete_cust_item.sub"; args = 2; Pick.mvSubroutine mysub = new Pick.mvSubroutine(subroutine, args, D3); mysub.SetArgs(0,ItemID); mysub.MvCall(); string Status = mysub.GetArgs(1); // gets the return values from the subroutine Add_Row.Visible = true; // swap the displayed buttons Insert.Visible = false; D3.CloseConnection(); //close out the connection to D3 } } else { MessageBox.Show(Account + ": Not Found", "Invalid Account", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Environment.Exit(0); } } else { MessageBox.Show("Unable to connect to D3", "Connection Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Environment.Exit(0); } }
public Invoices() { InitializeComponent(); StartPosition = FormStartPosition.CenterScreen; //center form this.FormClosing += Invoices_FormClosing; // set close event string hostName = "den-vm-dg02"; // replace with your host or leverage a config file or similar approach int hostPort = 9000; string userName = "******"; string userPassword = ""; Boolean x = false; string fileName = "customers"; string invoiceID = ""; string salesrep = ""; int args = 0; string subroutine = ""; String AcctSelection = formargs.AcctSelection; Pick D3 = new rocketsoftware.MVSP.Pick(); Functions func = new Functions(); x = D3.Connect(hostName, hostPort, userName, userPassword); bool acctstat = D3.Logto("acme", ""); // log over to the appropriate account String CustomerName = D3.FileReadv(fileName, AcctSelection, 1); // read the customer file to get the customer name label1.Text = "Invoices for Customer: " + CustomerName; // assign the customer name to the custmer name display // build the query to get the Invoice IDs that meet the selection criteria D3.ExecuteQuery("Query", "TRX.MST", "With cust.acct# = " + "" + AcctSelection + "" + " and with invoice.date", "by-dsnd invoice.date", " trx#", ""); int rowcount = D3.MVResultSetGetRowCount(); for (int i = 0; i < rowcount; i++) // loop through the ID list to read each matching Item { D3.MVResultSetNext(); invoiceID = D3.MVResultSetGetCurrentRow(); // gets the invoiceID from the result set to use for the subsequent readfile statements fileName = "TRX.MST"; string trxItem = D3.FileRead(fileName, invoiceID); string invoiceDate = func.Extract(trxItem,21); args = 2; subroutine = "date_convert.sub"; Pick.mvSubroutine mysub = new Pick.mvSubroutine(subroutine, args, D3); mysub.SetArgs(0, invoiceDate); mysub.SetArgs(1, ""); mysub.MvCall(); // call date conversion invoiceDate = mysub.GetArgs(1); string orderDate = func.Extract(trxItem,18); mysub.SetArgs(0, orderDate); mysub.MvCall(); // call date conversion orderDate = mysub.GetArgs(1); int TotalGross = Convert.ToInt32(func.Extract(trxItem,31)); int TotalDiscount = Convert.ToInt32(func.Extract(trxItem, 32)); int TotalNet = (TotalGross-TotalDiscount); string Comments = func.Extract(trxItem, 23); string TerrID = func.Extract(trxItem, 8); fileName = "territories"; string Terr_Results = D3.FileRead(fileName, TerrID); if (D3.statusCode !=0) { //if no territory there is no valid sales rep salesrep = ""; } else { string territory = func.Extract(Terr_Results, 2); fileName = "salesreps"; salesrep = D3.FileReadv(fileName, territory, 1); if (D3.statusCode !=0) {salesrep = ""; }// no sales rep for the territory } dataGridView2.Rows.Add(); dataGridView2.Rows[i].Cells[0].Value = invoiceID; dataGridView2.Rows[i].Cells[1].Value = invoiceDate; dataGridView2.Rows[i].Cells[2].Value = orderDate; dataGridView2.Rows[i].Cells[3].Value = salesrep; dataGridView2.Rows[i].Cells[4].Value = "Net 30"; // Terms not in database dataGridView2.Rows[i].Cells[5].Value = TotalGross; dataGridView2.Rows[i].Cells[6].Value = TotalDiscount; dataGridView2.Rows[i].Cells[7].Value = TotalNet; dataGridView2.Rows[i].Cells[8].Value = Comments; } D3.CloseConnection(); }
protected void Insert_Item_Click(object sender, EventArgs e) { string CUSTID = ((TextBox)Grid_CustList.FooterRow.FindControl("txtAcct")).Text; TextBox tx = (TextBox)Grid_CustList.FooterRow.FindControl("txtAcct"); if (string.IsNullOrEmpty(tx.Text)) { return; } string NAME = ((TextBox)Grid_CustList.FooterRow.FindControl("txtName")).Text; string ADDR = ((TextBox)Grid_CustList.FooterRow.FindControl("txtAddr")).Text; string CITY = ((TextBox)Grid_CustList.FooterRow.FindControl("txtCity")).Text; string STATE = ((TextBox)Grid_CustList.FooterRow.FindControl("txtState")).Text; string ZIP = ((TextBox)Grid_CustList.FooterRow.FindControl("txtZip")).Text; string PHONE = ((TextBox)Grid_CustList.FooterRow.FindControl("txtPhone")).Text; // ***************************** prepare and write data to D3 via Basic Subroutine Call ******************************* // assign connection values and create variables to use string hostName = "den-vm-dg02"; // replace with your host or leverage a config file or similar approach int hostPort = 9000; string userName = "******"; string userPassword = ""; Boolean x = false; string subroutine = "WriteCustItem.sub"; int args = 8; // 7 inputs and a retured status code String Account = "acme"; Pick D3 = new rocketsoftware.MVSP.Pick(); // make an instance of the D3 class Functions func = new Functions(); // make an instance of the Functions Class x = D3.Connect(hostName, hostPort, userName, userPassword); // connect to D3 and check status if (x) { bool acctstat = D3.Logto(Account, ""); //Move to the correct account //if (acctstat)..... would normally add error handling logic here //Prepare to call the subroutine that gets the customer lists Pick.mvSubroutine mysub = new Pick.mvSubroutine(subroutine, args, D3); mysub.SetArgs(0, CUSTID); // set the required arguments into the array for the arguments of the subroutine mysub.SetArgs(1, NAME); mysub.SetArgs(2, ADDR); mysub.SetArgs(3, CITY); mysub.SetArgs(4, STATE); mysub.SetArgs(5, ZIP); mysub.SetArgs(6, PHONE); mysub.SetArgs(7, ""); mysub.MvCall(); string STATUS = mysub.GetArgs(7); // gets the return values from the subroutine // Perform Error checking based on status returned // Retrieve the datatable from Session and add the row so we can dbind it back to the gridtable DataTable dt = (DataTable)(Session["dt_Table"]); dt.Rows.Add(); // add row to datatable so we can insert the new data dt.Rows[dt.Rows.Count - 1]["Account#"] = CUSTID; dt.Rows[dt.Rows.Count - 1]["Name"] = NAME; dt.Rows[dt.Rows.Count - 1]["Address"] = ADDR; dt.Rows[dt.Rows.Count - 1]["City"] = CITY; dt.Rows[dt.Rows.Count - 1]["State"] = STATE; dt.Rows[dt.Rows.Count - 1]["Zip"] = ZIP; dt.Rows[dt.Rows.Count - 1]["Phone"] = PHONE; Grid_CustList.DataSource = dt; Grid_CustList.DataBind(); Session["dt_table"] = dt; D3.CloseConnection(); //close out the connection to D3 } }
public Invoices() { InitializeComponent(); StartPosition = FormStartPosition.CenterScreen; //center form this.FormClosing += Invoices_FormClosing; // set close event string hostName = "den-vm-dg02"; // replace with your host or leverage a config file or similar approach int hostPort = 9000; string userName = "******"; string userPassword = ""; Boolean x = false; string fileName = "customers"; string invoiceID = ""; string salesrep = ""; int args = 0; string subroutine = ""; String AcctSelection = formargs.AcctSelection; Pick D3 = new rocketsoftware.MVSP.Pick(); Functions func = new Functions(); x = D3.Connect(hostName, hostPort, userName, userPassword); bool acctstat = D3.Logto("acme", ""); // log over to the appropriate account String CustomerName = D3.FileReadv(fileName, AcctSelection, 1); // read the customer file to get the customer name label1.Text = "Invoices for Customer: " + CustomerName; // assign the customer name to the custmer name display // build the query to get the Invoice IDs that meet the selection criteria D3.ExecuteQuery("Query", "TRX.MST", "With cust.acct# = " + "" + AcctSelection + "" + " and with invoice.date", "by-dsnd invoice.date", " trx#", ""); int rowcount = D3.MVResultSetGetRowCount(); for (int i = 0; i < rowcount; i++) // loop through the ID list to read each matching Item { D3.MVResultSetNext(); invoiceID = D3.MVResultSetGetCurrentRow(); // gets the invoiceID from the result set to use for the subsequent readfile statements fileName = "TRX.MST"; string trxItem = D3.FileRead(fileName, invoiceID); string invoiceDate = func.Extract(trxItem, 21); args = 2; subroutine = "date_convert.sub"; Pick.mvSubroutine mysub = new Pick.mvSubroutine(subroutine, args, D3); mysub.SetArgs(0, invoiceDate); mysub.SetArgs(1, ""); mysub.MvCall(); // call date conversion invoiceDate = mysub.GetArgs(1); string orderDate = func.Extract(trxItem, 18); mysub.SetArgs(0, orderDate); mysub.MvCall(); // call date conversion orderDate = mysub.GetArgs(1); int TotalGross = Convert.ToInt32(func.Extract(trxItem, 31)); int TotalDiscount = Convert.ToInt32(func.Extract(trxItem, 32)); int TotalNet = (TotalGross - TotalDiscount); string Comments = func.Extract(trxItem, 23); string TerrID = func.Extract(trxItem, 8); fileName = "territories"; string Terr_Results = D3.FileRead(fileName, TerrID); if (D3.statusCode != 0) { //if no territory there is no valid sales rep salesrep = ""; } else { string territory = func.Extract(Terr_Results, 2); fileName = "salesreps"; salesrep = D3.FileReadv(fileName, territory, 1); if (D3.statusCode != 0) { salesrep = ""; } // no sales rep for the territory } dataGridView2.Rows.Add(); dataGridView2.Rows[i].Cells[0].Value = invoiceID; dataGridView2.Rows[i].Cells[1].Value = invoiceDate; dataGridView2.Rows[i].Cells[2].Value = orderDate; dataGridView2.Rows[i].Cells[3].Value = salesrep; dataGridView2.Rows[i].Cells[4].Value = "Net 30"; // Terms not in database dataGridView2.Rows[i].Cells[5].Value = TotalGross; dataGridView2.Rows[i].Cells[6].Value = TotalDiscount; dataGridView2.Rows[i].Cells[7].Value = TotalNet; dataGridView2.Rows[i].Cells[8].Value = Comments; } D3.CloseConnection(); }
public Invoice() { InitializeComponent(); StartPosition = FormStartPosition.CenterScreen; //center form this.FormClosing += Invoice_FormClosing; // set close event var vm = (char)253; var svm = (char)252; string hostName = "den-vm-dg02"; // replace with your host or leverage a config file or similar approach int hostPort = 9000; string userName = "******"; string userPassword = ""; Boolean x = false; string Account = "acme"; string subroutine = "get_invoice.sub"; int args = 0; string InvoiceSelection = formargs.InvoiceSelection; Pick D3 = new rocketsoftware.MVSP.Pick(); Functions func = new Functions(); x = D3.Connect(hostName, hostPort, userName, userPassword); if (x) { bool acctstat = D3.Logto(Account, ""); //Move to the correct account if (acctstat) { args = 2; Pick.mvSubroutine mysub = new Pick.mvSubroutine(subroutine, args, D3); mysub.SetArgs(0, InvoiceSelection); mysub.SetArgs(1, ""); mysub.MvCall(); // call get_invoice.sub if (D3.statusCode != 0) { MessageBox.Show("Unable to execute:" + D3.ruleModule, "Subroutine Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Environment.Exit(0); } else { string InvoiceResult = mysub.GetArgs(1); AccountNo.Text = func.Extract(InvoiceResult, 1); BillTo.Text = func.Extract(InvoiceResult, 2); BillAddr.Text = func.Extract(InvoiceResult, 3); var BillCity = func.Extract(InvoiceResult, 4); var BillState = func.Extract(InvoiceResult, 5); var BillZip = func.Extract(InvoiceResult, 6); Bill_CityStateZip.Text = BillCity + ", " + BillState + " " + BillZip; Contact.Text = func.Extract(InvoiceResult, 7); InvoiceNo.Text = func.Extract(InvoiceResult, 8); ShipTo.Text = func.Extract(InvoiceResult, 9); ShipAddr.Text = func.Extract(InvoiceResult, 10); var ShipCity = func.Extract(InvoiceResult, 11); var ShipState = func.Extract(InvoiceResult, 12); var ShipZip = func.Extract(InvoiceResult, 13); Ship_CityStateZip.Text = ShipCity + ", " + ShipState + " " + ShipZip; SalesRep.Text = func.Extract(InvoiceResult, 15, 1); RepPhone.Text = func.Extract(InvoiceResult, 16, 2); Ordered.Text = func.Extract(InvoiceResult, 17); Invoiced.Text = func.Extract(InvoiceResult, 18); Terms.Text = func.Extract(InvoiceResult, 19); Note.Text = func.Extract(InvoiceResult, 20); Gross.Text = func.Extract(InvoiceResult, 21); Discount.Text = func.Extract(InvoiceResult, 22); Net.Text = func.Extract(InvoiceResult, 23); //declare the strings needed to do the deletes of the mv attributes that are not part of the line items so we can get an accurate count string LineResults1 = ""; string LineResults2 = ""; int mvLineCount = 7; LineResults1 = func.Delete(InvoiceResult, 15); LineResults2 = func.Delete(LineResults1, 15); int vmCount = func.Dcount(LineResults2, vm); int svmCount = func.Count(LineResults2, svm); // find out how many actual line items we have int itemCount = vmCount / mvLineCount; //Get Each Line Item for (int i = 0; i <= itemCount; i++) { dataGridView1.Rows.Add(); dataGridView1.Rows[i].Cells[0].Value = i + 1; // LineQty dataGridView1.Rows[i].Cells[1].Value = func.Extract(InvoiceResult, 24, i + 1); // Line Qty dataGridView1.Rows[i].Cells[2].Value = func.Extract(InvoiceResult, 25, i + 1); // Product Number dataGridView1.Rows[i].Cells[3].Value = func.Extract(InvoiceResult, 26, i + 1); // Description dataGridView1.Rows[i].Cells[4].Value = decimal.Parse(func.Extract(InvoiceResult, 27, i + 1)); // List or Unit Price dataGridView1.Rows[i].Cells[5].Value = decimal.Parse(func.Extract(InvoiceResult, 28, i + 1)); // Total Gross dataGridView1.Rows[i].Cells[6].Value = func.Extract(InvoiceResult, 29, i + 1); // Total Discount is a % dataGridView1.Rows[i].Cells[7].Value = decimal.Parse(func.Extract(InvoiceResult, 31, i + 1)); // Total Net } } } } }
protected void Page_Load(object sender, EventArgs e) { string hostName = "den-vm-dg02"; // replace with your host. Rather than hardcode you would want to leverage a config file or similar approach int hostPort = 9000; string userName = "******"; string userPassword = ""; Boolean x = false; string fileName = "customers"; string invoiceID = ""; string salesrep = ""; int args = 0; string subroutine = ""; String AcctSelection = Request.QueryString["param"]; Pick D3 = new rocketsoftware.MVSP.Pick(); Functions func = new Functions(); x = D3.Connect(hostName, hostPort, userName, userPassword); bool acctstat = D3.Logto("acme", ""); // log over to the appropriate account String CustomerName = D3.FileReadv(fileName, AcctSelection, 1); // read the customer file to get the customer name lbl_CustomeName.Text = CustomerName; // assign the customer name to the custmer name display // Create DataTable DataTable dt = new DataTable(); //map results into a dataTable that can be then bound to the dataGrid // Create the Headers for the DataTable that needs to mapped so that the DataGrid can bind to it. dt.Columns.Add("Invoice#", typeof(string)); dt.Columns.Add("InvoiceDate", typeof(string)); dt.Columns.Add("OrderDate", typeof(string)); dt.Columns.Add("Terms", typeof(string)); dt.Columns.Add("Gross", typeof(Int32)); dt.Columns.Add("Discount", typeof(Int32)); dt.Columns.Add("NetInvoice", typeof(Int32)); // build the query to get the Invoice IDs that meet the selection criteria D3.ExecuteQuery("Query", "TRX.MST", "With cust.acct# = " + "" + AcctSelection + "" + " and with invoice.date", "by-dsnd invoice.date", " trx#", ""); int rowcount = D3.MVResultSetGetRowCount(); for (int i = 0; i < rowcount; i++) // loop through the ID list to read each matching Item { D3.MVResultSetNext(); invoiceID = D3.MVResultSetGetCurrentRow(); // gets the invoiceID from the result set to use for the subsequent readfile statements fileName = "TRX.MST"; string trxItem = D3.FileRead(fileName, invoiceID); string invoiceDate = func.Extract(trxItem, 21); args = 2; subroutine = "date_convert.sub"; Pick.mvSubroutine mysub = new Pick.mvSubroutine(subroutine, args, D3); mysub.SetArgs(0, invoiceDate); mysub.SetArgs(1, ""); mysub.MvCall(); // call date conversion invoiceDate = mysub.GetArgs(1); string orderDate = func.Extract(trxItem, 18); mysub.SetArgs(0, orderDate); mysub.MvCall(); // call date conversion orderDate = mysub.GetArgs(1); // convert to int to do math int TotalGross = Convert.ToInt32(func.Extract(trxItem, 31)); int TotalDiscount = Convert.ToInt32(func.Extract(trxItem, 32)); int TotalNet = (TotalGross - TotalDiscount); string Comments = func.Extract(trxItem, 23); string TerrID = func.Extract(trxItem, 8); fileName = "territories"; string Terr_Results = D3.FileRead(fileName, TerrID); if (D3.statusCode != 0) { salesrep = ""; }// no sales rep for the territory else { string territory = func.Extract(Terr_Results, 2); fileName = "salesreps"; salesrep = D3.FileReadv(fileName, territory, 1); } dt.Rows.Add(); dt.Rows[dt.Rows.Count - 1]["Invoice#"] = invoiceID; dt.Rows[dt.Rows.Count - 1]["InvoiceDate"] = invoiceDate; dt.Rows[dt.Rows.Count - 1]["OrderDate"] = orderDate; dt.Rows[dt.Rows.Count - 1]["Terms"] = "Net 30"; // no terms in database dt.Rows[dt.Rows.Count - 1]["Gross"] = TotalGross; dt.Rows[dt.Rows.Count - 1]["Discount"] = TotalDiscount; dt.Rows[dt.Rows.Count - 1]["NetInvoice"] = TotalNet; } Grid_Invoices.DataSource = dt; Grid_Invoices.DataBind(); D3.CloseConnection(); }