Hello I have created a routine to connect two Systems: XXXXWIN10 that is a local system with Acumatica. XXXWIN10 system have to send information about sales order to Acumatica. I'm using screen webservice in order to create a Sales Order. When I execute to test my code, each time I receive that customerID could not be empty but I'm sending all the information and also the customer exist. Do you see something wrong in my code:
using System;
using System.Net.Security;
using System.Net;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Conexionspa.apitest;
using System.Globalization;
namespace Conexionspa
{
class Program
{
static void Main(string[] args)
{
string CVECLI = "";
string CVEORDEN = "";
string FEC_ORDEN = "";
string DESCUENTO = "";
string CVESERVI = "";
string CANTIDAD = "";
decimal QTY = 0;
string PIEZAS = "";
string CAPA_REQ = "";
string CAPA_OBT = "";
string KILOS = "";
string TIPO_ACERO = "";
string RECIPIENTE = "";
string DUREZA_OBT = "";
string FEC_PROMES = "";
string PRECIOME = "";
decimal PRECIO = 0;
string IMPORTE = "";
string PORPIEZA = "";
string MONEDA = "";
string TIPOCAMBIO = "";
string PLANTA = "";
string conexion = #"Data Source = XXXXWIN10,2433; Initial Catalog = SYSXXXX; User ID = sa; Password = XXXYYYZZZ";
string queryString = "SELECT CVECLI, CVEORDEN, FEC_ORDEN, DESCUENTO, CVESERVI, CANTIDAD, PIEZAS, CAPA_REQ, CAPA_OBT, KILOS, TIPO_ACERO, RECIPIENTE, DUREZA_OBT, FEC_PROMES, PRECIOME, IMPORTE, PORPIEZA, MONEDA, TIPOCAMBIO, PLANTA FROM [Ordenes de Trabajo] WHERE STATUS = 2";
SqlConnection conection = new SqlConnection(conexion);
try
{
conection.Open();
SqlDataReader leeordenes = null;
SqlCommand Command = new SqlCommand(queryString, conection);
leeordenes = Command.ExecuteReader();
while (leeordenes.Read())
{
CVECLI = leeordenes["CVECLI"].ToString();
CVEORDEN = leeordenes["CVEORDEN"].ToString();
FEC_ORDEN = leeordenes["FEC_ORDEN"].ToString();
DateTime FECORDEN = DateTime.Parse(FEC_ORDEN);
DESCUENTO = leeordenes["DESCUENTO"].ToString();
CVESERVI = leeordenes["CVESERVI"].ToString();
CANTIDAD = leeordenes["CANTIDAD"].ToString();
decimal.TryParse(CANTIDAD, out QTY);
PIEZAS = leeordenes["PIEZAS"].ToString();
CAPA_REQ = leeordenes["CAPA_REQ"].ToString();
CAPA_OBT = leeordenes["CAPA_OBT"].ToString();
KILOS = leeordenes["KILOS"].ToString();
TIPO_ACERO = leeordenes["TIPO_ACERO"].ToString();
RECIPIENTE = leeordenes["RECIPIENTE"].ToString();
DUREZA_OBT = leeordenes["DUREZA_OBT"].ToString();
FEC_PROMES = leeordenes["FEC_PROMES"].ToString();
DateTime FECPROMES = DateTime.Parse(FEC_PROMES);
PRECIOME = leeordenes["PRECIOME"].ToString();
decimal.TryParse(PRECIOME, out PRECIO);
IMPORTE = leeordenes["IMPORTE"].ToString();
PORPIEZA = leeordenes["PORPIEZA"].ToString();
MONEDA = leeordenes["MONEDA"].ToString();
TIPOCAMBIO = leeordenes["TIPOCAMBIO"].ToString();
PLANTA = leeordenes["PLANTA"].ToString();
apitest.Screen context = new apitest.Screen();
context.CookieContainer = new CookieContainer();
context.AllowAutoRedirect = true;
context.EnableDecompression = true;
context.Timeout = 1000000;
context.Url = "http://localhost/XXXYYY/Soap/APITEST.asmx";
try
{
LoginResult result = context.Login("Admin#XXXYYY:P000", "AdminXXX");
}
catch(Exception ep)
{
Console.WriteLine("Error en las credenciales" + ep.Message );
}
try
{
SO301000Content SO301000 = context.SO301000GetSchema();
context.SO301000Clear();
SO301000Content[] SO301000result = context.SO301000Submit
(
new Command[]
{
new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType },
new Value { Value = "TADEO", LinkedCommand = SO301000.OrderSummary.Customer },
new Value { Value = "0000007", LinkedCommand = SO301000.OrderSummary.OrderNbr },
new Value { Value = CVEORDEN, LinkedCommand = SO301000.OrderSummary.ExternalReference },
new Value { Value = FEC_ORDEN, LinkedCommand = SO301000.OrderSummary.Date },
new Value { Value = CVESERVI, LinkedCommand = SO301000.DocumentDetails.InventoryID },
new Value { Value = CANTIDAD, LinkedCommand = SO301000.DocumentDetails.Quantity },
new Value { Value = PIEZAS, LinkedCommand = SO301000.OrderSummary.Description },
new Value { Value = CAPA_REQ + " " + CAPA_OBT + " " + KILOS + " " + TIPO_ACERO + " " + RECIPIENTE + " " + DUREZA_OBT, LinkedCommand = SO301000.DocumentDetails.LineDescription },
new Value { Value = FEC_ORDEN, LinkedCommand = SO301000.OrderSummary.RequestedOn },
new Value { Value = PRECIOME, LinkedCommand = SO301000.DocumentDetails.UnitPrice, Commit = true },
new Value { Value = "NA", LinkedCommand = SO301000.DocumentDetails.UOM },
new Value { Value = "USD", LinkedCommand = SO301000.OrderSummary.Currency },
new Value { Value = "AP3", LinkedCommand = SO301000.DocumentDetails.Warehouse },
SO301000.Actions.Save,
}
);
Console.WriteLine("Orden registrada");
Thread.Sleep(9000);
}
catch(Exception ex)
{
Console.WriteLine("Error al insertar O.T en Acumatica: " + ex.Message);
Thread.Sleep(5000);
}
}
}
catch (Exception mensaje)
{
Console.WriteLine("Error en las credenciales del SPA ó Acumatica Web Service: " + mensaje);
Thread.Sleep(5000);
}
}
}
}
As far as I know, you should first set Order Type and Order Number, and only then all the other fields, i.e.
new Command[]
{
new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType },
new Value { Value = "0000007", LinkedCommand = SO301000.OrderSummary.OrderNbr },
new Value { Value = "TADEO", LinkedCommand = SO301000.OrderSummary.Customer },
//rest of fields
SO301000.Actions.Save,
}
Related
I create a program who I need to compare two Chinese characters.
I use this function to compare :
void fengshuitradition::comparerAuto()
{
Stockage obj_stockage;
Lunar lunar;
LunarObj* obj = lunar.solar2lunar(ui->SBSelection_4->value(), ui->SBSelection_3->value(), ui->SBSelection_2->value());
string day = obj->ganzhiDay;
for(int i = 0; i<64; i++)
{
string jourComparer = obj_stockage.appelStockage(i,1);
string jourComparer2 = obj_stockage.appelStockage(i,2);
if (day.compare(0,6,jourComparer,0,6) == 0 && day.compare(7,6,jourComparer2,0,6) == 0)
{
ui->label_0->setText(obj_stockage.appelStockage(i,0));
ui->label_1->setText(obj_stockage.appelStockage(i,1));
ui->label_2->setText(obj_stockage.appelStockage(i,2));
ui->label_3->setText(obj_stockage.appelStockage(i,3));
ui->label_4->setText(obj_stockage.appelStockage(i,4));
ui->label_5->setText(obj_stockage.appelStockage(i,5));
ui->label_6->setText(obj_stockage.appelStockage(i,6));
return;
}
}
}
My values are stock like this :
const char* stockage[64][7] = {
{"1",
"\u7532 B+",
u8"\u5b50 E+ hiver",
"24 F",
"8",
"癸E-",
". ."},
// ainsi de suite
And I use a library :
static std::string Gan[] = {"\u7532","\u4e59","\u4e19","\u4e01","\u620a","\u5df1","\u5e9a","\u8f9b","\u58ec","\u7678"};
static std::string Zhi[] = {"\u5b50","\u4e11","\u5bc5","\u536f","\u8fb0","\u5df3","\u5348","\u672a","\u7533","\u9149","\u620c","\u4ea5"};
Thanks for your help.
I'm trying to convert some strings, I'd like to be able to remove diacritics from strinf. (Exemple : éùèà would become euea)
i have try this :
static str AALRemoveDiacritics( System.String input )
{
int i;
System.Text.NormalizationForm FormD;
str normalizedString = input.Normalize(FormD);
System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
for (i = 0; i < strLen(normalizedString); i++)
{
System.Char c = normalizedString[i];
if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)
{
stringBuilder.Append(c);
}
}
return stringBuilder.ToString().Normalize(NormalizationForm.FormC);
}
It looks like you tried making this post work in X++ and were very close.
Here's a working job I just wrote you can use:
static void AlexRemoveDiacritics(Args _args)
{
str strInput = 'ÁÂÃÄÅÇÈÉàáâãäåèéêëìíîïòóôõ£ALEX';
System.String input = strInput;
str retVal;
int i;
System.Char c;
System.Text.NormalizationForm FormD = System.Text.NormalizationForm::FormD;
str normalizedString = input.Normalize(FormD);
System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
for (i = 0; i <= strLen(normalizedString); i++)
{
c = System.Char::Parse(subStr(normalizedString, i, 1));
if (System.Globalization.CharUnicodeInfo::GetUnicodeCategory(c) != System.Globalization.UnicodeCategory::NonSpacingMark)
{
stringBuilder.Append(c);
}
}
input = stringBuilder.ToString();
input = input.Normalize();
retVal = input;
info(strFmt("Before: '%1'", strInput));
info(strFmt("After: '%1'", retVal));
}
SqlConnection con = new SqlConnection(#"Data Source=(local)\SQLEXPRESS; Integrated Security= SSPI;" + "Initial Catalog = CarRent_vaxo;");
con.Open();
string strSQL = "select * from AccesList";
SqlCommand myCommand = new SqlCommand(strSQL, con);
using (SqlDataReader myDataReader = myCommand.ExecuteReader())
{
myDataReader.Read();
{
if (usertextBox.Text == myDataReader["User"].ToString() && paswordTextBox.Text == myDataReader["Password"].ToString())
{
this.Hide();
ResultForm rf = new ResultForm();
rf.Show();
}
else if (usertextBox.Text == "" || paswordTextBox.Text == "")
{
Notificarion2.Text = "PLEASE FILL THE BOXES !!!";
}
else
{
Notificarion2.Text = "WRONG USER OR PASSWORD !!!";
usertextBox.Text = "";
paswordTextBox.Text = "";
}
}
}
You should read from SqlDataReader in a while loop as
while (myDataReader.Read())
{
//your code goes here
}
myDataReader.Close();
http://msdn.microsoft.com/en-us/library/haa3afyz%28v=vs.110%29.aspx
i have built a fully working search page for my WebMatrix property site. To summarize, it checks the query string, and if any of the defined values are present, it adds it to a list so it can iterate through them.
The problem, as you will see, if that it currently adds everything to the list as a string. This causes problems when i need to use the value as an INT (PropertyType and NumBedrooms should be int's). is there a way i can use both strings and int's in this scenario? can i add ints AND strings to the same list?
here's the code:
var db = Database.Open("StayInFlorida");
var proptype = db.Query("SELECT * FROM Property_Type");
IEnumerable<dynamic> queryResults;
//Search Variables
string searchTerm = "";
string resortID = "";
string propertyType = "";
string numBedrooms = "";
List<string> argList = new List<string>();
//Paging Variables
var pageSize = 6;
var totalPages = 0;
var count = 0;
var page = UrlData[0].IsInt() ? UrlData[0].AsInt() : 1;
var offset = (page -1) * pageSize;
//Request querystrings from URL
if (!String.IsNullOrWhiteSpace(Request.QueryString["searchTerm"]))
{
searchTerm = Request.QueryString["searchTerm"];
}
if (!String.IsNullOrWhiteSpace(Request.QueryString["resortID"]))
{
resortID = Request.QueryString["resortID"];
}
if (!String.IsNullOrWhiteSpace(Request.QueryString["propertyType"]))
{
propertyType = Request.QueryString["propertyType"];
}
if (!String.IsNullOrWhiteSpace(Request.QueryString["numBedrooms"]))
{
numBedrooms = Request.QueryString["numBedrooms"];
}
int numOfArguments = 0;
string selectQueryString = "SELECT * FROM Property_Info ";
if (searchTerm != "")
{
argList.Add(searchTerm);
selectQueryString += "WHERE FullDescription LIKE '%' + #0 + '%' OR BriefDescription LIKE '%' + #0 + '%' ";
numOfArguments++; //increment numOfArguments by 1
}
if (resortID != "")
{
argList.Add(resortID);
if (numOfArguments == 0)
{
selectQueryString += "WHERE ResortID = #0 ";
}
else
{
selectQueryString += "AND ResortID = #" + numOfArguments + " ";
}
numOfArguments++;
}
if (propertyType != "")
{
argList.Add(propertyType);
if (numOfArguments == 0)
{
selectQueryString += "WHERE PropertyTypeID = #0 ";
}
else
{
selectQueryString += "AND PropertyTypeID = #" + numOfArguments + " ";
}
numOfArguments++;
}
if (numBedrooms != "")
{
argList.Add(numBedrooms);
if (numOfArguments == 0)
{
selectQueryString += "WHERE NumBedrooms = #0 ";
}
else
{
selectQueryString += "AND NumBedrooms = #" + numOfArguments + " ";
}
numOfArguments++;
}
selectQueryString += "ORDER BY CreatedDate DESC";
string[] argArray = argList.ToArray();
queryResults = db.Query(selectQueryString, argArray);
count = queryResults.Count();
totalPages = count/pageSize;
if(count % pageSize > 0){
totalPages += 1;
}
Edited code after Polynomial's suggestion:
#{
Layout = "~/_SiteLayout.cshtml";
Page.Title = "Search Page";
var db = Database.Open("StayInFlorida");
var proptype = db.Query("SELECT * FROM Property_Type");
//Paging Variables
var pageSize = 6;
var totalPages = 0;
var count = 0;
var page = UrlData[0].IsInt() ? UrlData[0].AsInt() : 1;
var offset = (page -1) * pageSize;
IEnumerable<dynamic> queryResults;
//Request querystrings from URL
string selectQueryString = "SELECT * FROM Property_Info WHERE 0 = 0 AND NumBedrooms = #0 AND NumBathrooms = #1 ";
selectQueryString += "ORDER BY CreatedDate DESC";
queryResults = db.Query(selectQueryString, Request.QueryString["NumBedrooms"], Request.QueryString["NumBathrooms"]);
count = queryResults.Count();
totalPages = count/pageSize;
if(count % pageSize > 0){
totalPages += 1;
}
}
Well, there are lots of ways around the problem, I'm thinking the easiest one that doesn't involve not using named ordinal parameterization would be to use fixed ordinals for each search criteria and just not use the ones you don't need in the SQL statement. Your code is very long so I don't really want to try and rewrite the whole thing here, but basically if your db.Query() call has all of the potential arguments passed as parameters like this:
queryResults = db.Query(selectQueryString, Request.QueryString["searchTerm"], Request.QueryString["resortId"]).AsInt(), Request.QueryString["propertyType"].AsInt() /* etc etc */);
Then your ordinals are always the same number. searchTerm is always #0, resortId is always #1 etc, etc. You then don't need the array at all and just need to build up an appropriate SQL statement for what the user specified, for example some WHERE clauses that would all fit with the code above could be:
"WHERE ResortID = #1"
"WHERE PropertyType = #2"
"WHERE ResortID = #1 AND PropertyType = #2"
"WHERE Name = #0"
"WHERE Name = #0 AND ResortID = #1 AND PropertyType = #2"
In the case of the clauses that only use one or two of the parameters, the others are just ignored and hopefully everything will work as you intend.
Edit to show code:
// Basic beginning of the select statement
string selectQueryString = "SELECT * FROM Property_Info WHERE 0 = 0 ";
// Check to see if the user specified bedrooms, if they did add to the select statement
if (Request.QueryString["NumBedrooms"].AsInt() > 0)
{
selectQueryString += "AND NumBedrooms = #0 ";
}
// Same for the number of bathrooms
if (Request.QueryString["NumBathrooms"].AsInt() > 0)
{
selectQueryString += "AND NumBathrooms = #1 ";
}
// ** Add more criteria to your select list here by checking for valid values and concatenating your string **
// Finally add the order by on the end
selectQueryString += "ORDER BY CreatedDate DESC";
// Execute the statement
queryResults = db.Query(selectQueryString, Request.QueryString["NumBedrooms"].AsInt(), Request.QueryString["NumBathrooms"].AsInt());
This should give you a very flexible and expandable search criteria system that is happy with zero, one or many criteria.
I'd like to be able to load custom key binds for my application. A configuration file would typically contain a list of keys and associated function names.
When I load this file, is there a way to iterate over all the possible virtual keys that would be listed inside the configuration file in the form:
for(int i = key0; i < keymax; i = i+key){
char key = itoa(i);
if(cfgfile.getfunction(key,function)){
_keyBinds[key] = function;
}
}
Or do I need to manually check for every one of them ?
This is the way I finally proceeded to create a map of the keyboard keys. It covers almost all possibilities: non-mappable keys are stored as a hex string, mappable keys which do not represent themselves as a single caracter need to be added manually. Maybe this can be usefull for someone in the future.
CreateKeyboardMap()
{
string keystring;
char keybuffer;
for(int i = 0; i < 256; ++i){
if(keybuffer = MapVirtualKey(UINT(i),2)){
keystring += keybuffer;
}
else{
keystring = int_to_hex(i);
}
_keyboardMap.insert(_keyboardMap.end(),pair<UINT,string>(i,keystring));
keystring = "";
}
_keyboardMap[0x1B] = "ESCAPE";
_keyboardMap[0x70] = "F1";
_keyboardMap[0x71] = "F2";
_keyboardMap[0x72] = "F3";
_keyboardMap[0x73] = "F4";
_keyboardMap[0x74] = "F5";
_keyboardMap[0x75] = "F6";
_keyboardMap[0x76] = "F7";
_keyboardMap[0x77] = "F8";
_keyboardMap[0x78] = "F9";
_keyboardMap[0x79] = "F10";
_keyboardMap[0x7A] = "F11";
_keyboardMap[0x7B] = "F12";
_keyboardMap[0x2C] = "PRINT SCREEN";
_keyboardMap[0x91] = "SCROLL LOCK";
_keyboardMap[0x08] = "BACKSPACE";
_keyboardMap[0x20] = "SPACE";
_keyboardMap[0x2D] = "INSERT";
_keyboardMap[0x24] = "HOME";
_keyboardMap[0x22] = "PAGE DOWN";
_keyboardMap[0x21] = "PAGE UP";
_keyboardMap[0x2E] = "DELETE";
_keyboardMap[0x90] = "NUMLOCK";
_keyboardMap[0x6F] = "NUMPAD /";
_keyboardMap[0x6A] = "NUMPAD *";
_keyboardMap[0x6D] = "NUMPAD -";
_keyboardMap[0x6B] = "NUMPAD +";
_keyboardMap[0x6E] = "NUMPAD .";
_keyboardMap[0x60] = "NUMPAD 0";
_keyboardMap[0x61] = "NUMPAD 1";
_keyboardMap[0x62] = "NUMPAD 2";
_keyboardMap[0x63] = "NUMPAD 3";
_keyboardMap[0x64] = "NUMPAD 4";
_keyboardMap[0x65] = "NUMPAD 5";
_keyboardMap[0x66] = "NUMPAD 6";
_keyboardMap[0x67] = "NUMPAD 7";
_keyboardMap[0x68] = "NUMPAD 8";
_keyboardMap[0x68] = "NUMPAD 9";
_keyboardMap[0x26] = "ARROW UP";
_keyboardMap[0x28] = "ARROW DOWN";
_keyboardMap[0x25] = "ARROW LEFT";
_keyboardMap[0x27] = "ARROW RIGHT";
_keyboardMap[0x0D] = "ENTER";
_keyboardMap[0xA0] = "LSHIFT";
_keyboardMap[0xA1] = "RSHIFT";
_keyboardMap[0x09] = "TAB";
_keyboardMap[0x14] = "CAPS LOCK";
_keyboardMap[0xA2] = "LCONTROL";
_keyboardMap[0xA3] = "RCONTROL";
_keyboardMap[0xA4] = "LALT";
_keyboardMap[0xA5] = "RALT";
_keyboardMap[0x5B] = "LWIN";
_keyboardMap[0x5C] = "RWIN";
}
In your routine that loads the contents of the file, you'll want to store the data in a map with the keycodes as the keys and function names as the values. Instead of iterating over all possible keycodes, then, just iterate over the entries in the map.