public bool retrieveData() { Int16 iReceipts = 0; Int16 iCredits = 0; Int16 iDiscounts = 0; Int16 iAdjustments = 0; try { iReceipts = Convert.ToInt16(trxType.Substring(0, 1)); iCredits = Convert.ToInt16(trxType.Substring(1, 1)); iDiscounts = Convert.ToInt16(trxType.Substring(2, 1)); iAdjustments = Convert.ToInt16(trxType.Substring(3, 1)); } catch { } //dd/mm/yyyy DateTime dTrxFrom = Convert.ToDateTime(crdTrxFrom.Substring(0, 2) + "/" + crdTrxFrom.Substring(2, 2) + "/" + crdTrxFrom.Substring(4, 4)); DateTime dTrxTo = Convert.ToDateTime(crdTrxTo.Substring(0, 2) + "/" + crdTrxTo.Substring(2, 2) + "/" + crdTrxTo.Substring(4, 4)); int ix = 0; stpCaller stpC = new stpCaller(); List <object> arrPar = new List <object>(); //cardType = -1 (retrieve all customers with current transactions within specified date range) //cardType = 0 (retrieve all customers active/inactive) //cardType = 1 (retrieve active customers only) //populate header arrPar.Add("Header"); arrPar.Add(clientID); arrPar.Add(0); arrPar.Add(cardType); arrPar.Add(dTrxFrom); arrPar.Add(dTrxTo); arrPar.Add(this.lastSaleID); //last sale ID arrPar.Add(this.lastReceiptID); //last receipt ID System.Data.DataSet theDS = stpC.executeSPDataSet(arrPar, stpCaller.stpType.cff2MYOB); if (theDS == null) { return(false); } System.Data.DataTable theTable = theDS.Tables[0]; System.Data.DataRow dRow = theTable.Rows[0]; s_Header.uniquenum = clientID.ToString(); s_Header.companyName = dRow["ClientName"].ToString(); s_Header.dbaseVersion = dRow["DatabaseVersion"].ToString(); s_Header.driverBuilderNo = dRow["DriverBuildNumber"].ToString(); _depositPaymentAccount = Convert.ToInt32(dRow["PaymentDepositAcct"]); s_Header.changeControl = dRow["ChangeControl"].ToString(); s_Header.isOpenItem = dRow["isOpenItem"].ToString(); if (iReceipts == 1) { //retrieve receipts arrPar[0] = "Receipts"; theDS = stpC.executeSPDataSet(arrPar, stpCaller.stpType.cff2MYOB); if (theDS == null) { return(false); } theTable = theDS.Tables[0]; s_Receipts = new List <sPayments>(); if (theTable == null) { return(false); } if (theTable.Rows.Count > 0) { bReceipts = true; } for (ix = 0; ix < theTable.Rows.Count; ix++) { dRow = theTable.Rows[ix]; s_Receipts.Add(assignPayments(dRow)); } } if (iDiscounts == 1) { //retrieve discounts arrPar[0] = "Discounts"; theDS = stpC.executeSPDataSet(arrPar, stpCaller.stpType.cff2MYOB); if (theDS == null) { return(false); } theTable = theDS.Tables[0]; s_Discounts = new List <sPayments>(); if (theTable == null) { return(false); } if (theTable.Rows.Count > 0) { bDiscounts = true; } for (ix = 0; ix < theTable.Rows.Count; ix++) { dRow = theTable.Rows[ix]; s_Discounts.Add(assignPayments(dRow)); } } if (iCredits == 1) { //retrieve settled credits //note that settled credits may be partially allocated arrPar[0] = "SettledCredits"; theDS = stpC.executeSPDataSet(arrPar, stpCaller.stpType.cff2MYOB); if (theDS == null) { return(false); } theTable = theDS.Tables[0]; s_Credits = new List <sCredits>(); if (theTable == null) { return(false); } if (theTable.Rows.Count > 0) { bCredits = true; } for (ix = 0; ix < theTable.Rows.Count; ix++) { dRow = theTable.Rows[ix]; s_Credits.Add(assignCredits(dRow)); } //retrieve unsettled credits arrPar[0] = "UnsettledCredits"; theDS = stpC.executeSPDataSet(arrPar, stpCaller.stpType.cff2MYOB); if (theDS == null) { return(false); } theTable = theDS.Tables[0]; if (s_Credits == null) { s_Credits = new List <sCredits>(); } if (theTable == null) { return(false); } if (theTable.Rows.Count > 0) { bCredits = true; } for (ix = 0; ix < theTable.Rows.Count; ix++) { dRow = theTable.Rows[ix]; s_Credits.Add(assignCredits(dRow)); } } if (iAdjustments == 1) {//retrieve adjustsments - posted as negative invoice arrPar[0] = "Adjustments"; theDS = stpC.executeSPDataSet(arrPar, stpCaller.stpType.cff2MYOB); if (theDS == null) { return(false); } theTable = theDS.Tables[0]; //we are listing adjustments as negative invoice s_Invoices = new List <sInvoices>(); if (theTable == null) { return(false); } bAdjustments = (theTable.Rows.Count > 0) ? true : false; for (ix = 0; ix < theTable.Rows.Count; ix++) { dRow = theTable.Rows[ix]; } return(true); } return(true); }
private void updateCurrentNotes(string letterName) { string strYrMth = Convert.ToDateTime(docBag.DateStamp).Year.ToString() + Convert.ToDateTime(docBag.DateStamp).Month.ToString().PadLeft(2, '0'); List <object> objParams = new List <object>(); objParams.Add(docBag.ClientID); objParams.Add(docBag.CustomerID); objParams.Add(Convert.ToInt16(docBag.LetterIdx)); objParams.Add(letterName); objParams.Add(docBag.DateStamp); objParams.Add(Convert.ToInt32(strYrMth)); objParams.Add(docBag.UserID); objParams.Add(docBag.FileAttachment); objParams.Add(docBag.Notes); // MSarza[20160922] try { stpCaller stpc = new stpCaller(); var ret = stpc.executeSP(objParams, stpCaller.stpType.InsertLetterSent); objParams.Clear(); objParams.Add(1); objParams.Add(docBag.CustomerID); objParams.Add(docBag.UserID); objParams.Add(Convert.ToInt32(strYrMth)); System.Data.DataSet DS = stpc.executeSPDataSet(objParams, stpCaller.stpType.GetNotesCurrent); int notesid = 0; // MSarza [20160922]: As per Marty, instead of updating notes new notes must be inserted instead // like the VB app behaves. Also, as with the VB app, permanent notes must be inserted // for letters names like: (1) 7 Day, (2) Default, (3) AEL, and (4) Credit Consultants //bool doInsert = false; //if (DS == null) { doInsert = true; } //else if (DS.Tables.Count == 0) //{ doInsert = true; } //else if (DS.Tables[0].Rows.Count == 0) //{ doInsert = true; } //else if (DS.Tables[0].Rows.Count > 0) //{ // System.Data.DataRow DR = DS.Tables[0].Rows[0]; // if (Convert.ToInt32(DR["yrMth"]) == Convert.ToInt32(strYrMth)) // { // doInsert = false; // notesid = Convert.ToInt32(DR["NotesID"]); // docBag.Notes = DR["notes"] + System.Environment.NewLine + "[C " + docBag.Notes + "]"; // } // else { doInsert = true; } //} objParams.Clear(); objParams.Add(notesid); objParams.Add(docBag.CustomerID); objParams.Add(docBag.Notes); objParams.Add(docBag.DateStamp); objParams.Add(docBag.UserID); //if (doInsert) //{ //insert current notes ret = stpc.executeSP(objParams, stpCaller.stpType.InsertCurrentNotes); //} //else //{ //update current notes // ret = stpc.executeSP(objParams, stpCaller.stpType.UpdateCurrentNotes); //} string[] letterNamesReqPermNotes = { "7 Day", "Default", "AEL", "Credit Consultants" }; bool updatePermNotes = false; foreach (string lnreq in letterNamesReqPermNotes) { if (letterName.Contains(lnreq)) { updatePermNotes = true; } } if (updatePermNotes) { //MSarza[20161003]: Store proc for inserting current notes generates its own current datetime and uses it as the // created date for inserting records; the insert permanent notes doesn't. The insert permanent // notes uses the datetime parameter passed to it, hence, generating a current date time as here // to be passed as the create date to the stored procedure DateTime dt = DateTime.Now; string x; string m; string d; int dt1; int dt2; //x = "0" + docBag.DateStamp.Month.ToString(); x = "0" + dt.Month.ToString(); m = x.Substring(x.Length - 2); //x = "0" + docBag.DateStamp.Day.ToString(); x = "0" + dt.Day.ToString(); d = x.Substring(x.Length - 2); dt1 = int.Parse(docBag.DateStamp.Year.ToString() + m); dt2 = int.Parse(docBag.DateStamp.Year.ToString() + m + d); objParams.Add(dt); objParams.Add(dt1); objParams.Add(dt2); ret = stpc.executeSP(objParams, stpCaller.stpType.InsertNotesPermanent); } } catch (Exception e) { string x = e.ToString(); } }