Exemplo n.º 1
0
        private void BtnComplete_Click(object sender, RoutedEventArgs e)
        {
            paymentPopup.IsOpen           = false;
            productCat_ListBox.Visibility = Visibility.Visible;
            Product_ListBox.Visibility    = Visibility.Visible;
            onHoldOrders.Visibility       = Visibility.Hidden;
            holdRecoll.Content            = "Recall";

            try
            {
                List <apiInvoiceList> invoiceLists = new List <apiInvoiceList>();

                invoiceLists.Add(new apiInvoiceList
                {
                    payAmount   = payableAmount.ToString(),
                    grandTotal  = payableAmount.ToString(),
                    invoiceDate = invoiceDatetime.ToString(),
                    posId       = "1192016235",
                    invoiceId   = invoiceno.ToString(),
                    documentNo  = "ALW4145"
                });

                List <PostVendorInvoicePayments> paymentData = new List <PostVendorInvoicePayments>();

                paymentData.Add(new PostVendorInvoicePayments
                {
                    macAddress        = "8e17517b8cd41f3c",
                    clientId          = _clientId,
                    orgId             = _OrgId.ToString(),
                    warehouseId       = _Warehouse_Id.ToString(),
                    userId            = _UserID.ToString(),
                    version           = "2.0",
                    appName           = "POS",
                    operation         = "PostVendorInvoicePayments",
                    businessPartnerId = _Bpartner_Id.ToString(),
                    description       = txtReason.Text,
                    cashbookId        = "1000021",
                    tenderType        = "X",
                    payAmount         = payableAmount.ToString(),
                    isCustomer        = "Y",
                    isVendor          = "N",
                    invoiceList       = invoiceLists
                });
                object jsonq = JsonConvert.SerializeObject(paymentData);

                var loginApiStringResponce = PostgreSQL.ApiCallPost(jsonq.ToString());

                using (NpgsqlConnection connection = new NpgsqlConnection(connstring))
                {
                    connection.Open();
                    NpgsqlCommand INSERT_c_invoicepaymentdetails = new NpgsqlCommand("INSERT INTO c_invoicepaymentdetails(" +
                                                                                     " ad_client_id, ad_org_id, c_invoice_id," +
                                                                                     "cash, card, exchange, redemption, iscomplementary, iscredit, createdby, updatedby)" +
                                                                                     "VALUES(" + _clientId + "," + _OrgId + "," + invoiceno + "," + payableAmount + ",0,0,0,'N','N'," + _UserID + "," + _UserID + "); ", connection);
                    INSERT_c_invoicepaymentdetails.ExecuteNonQuery();

                    //NpgsqlCommand cmd_update_sequenc_no = new NpgsqlCommand("UPDATE ad_sequence SET currentnext =" + _sequenc_id + " WHERE name = 'c_invoicepaymentdetails';", connection);
                    //NpgsqlDataReader _update__Ad_sequenc_no = cmd_update_sequenc_no.ExecuteReader();
                    MessageBox.Show("cash paymen completed successfully");
                }
            }
            catch (Exception x)
            {
                Console.WriteLine(x.Message);
            }
        }
Exemplo n.º 2
0
        private void SessionCreateNew_Click(object sender, RoutedEventArgs e)
        {
            NpgsqlConnection connection = new NpgsqlConnection(PostgreSQL.ConnectionString);

            SessionCart CreateSession = new SessionCart
            {
                operation         = "createSession",
                username          = RetailPage.AD_UserName,
                password          = RetailPage.AD_UserPassword,
                clientId          = RetailPage.AD_Client_ID.ToString(),
                orgId             = RetailPage.AD_ORG_ID.ToString(),
                userId            = RetailPage.AD_USER_ID.ToString(),
                businessPartnerId = RetailPage.AD_bpartner_Id.ToString(),
                roleId            = RetailPage.AD_ROLE_ID.ToString(),
                warehouseId       = RetailPage.AD_Warehouse_Id.ToString(),
                remindMe          = "Y",
                macAddress        = "54:C9:DF:B8:23:B6", //LoginViewModel._DeviceMacAddress,
                version           = "1.0",
                appName           = "POS",
            };

            jsonCreateSession = JsonConvert.SerializeObject(CreateSession);
            try
            {
                CreateSessionApiStringResponce = PostgreSQL.ApiCallPost(jsonCreateSession);
                CheckServerError = 1;
            }
            catch
            {
                CheckServerError = 0;
            }
            if (CheckServerError == 1)
            {
                CreateSessionApiJSONResponce = JsonConvert.DeserializeObject(CreateSessionApiStringResponce);

                if (CreateSessionApiJSONResponce.responseCode == "200")
                {
                    double _sessionId = CreateSessionApiJSONResponce.sessionId;
                    RetailPage.AD_SessionID = _sessionId;

                    connection.Close();

                    connection.Open();
                    NpgsqlCommand cmd_select_sequenc_no = new NpgsqlCommand("UPDATE ad_user_pos " +
                                                                            "SET sessionid = " + _sessionId + " " +
                                                                            "WHERE ad_client_id = " + RetailPage.AD_Client_ID + "  and ad_org_id = " + RetailPage.AD_ORG_ID + " and ad_user_id = " + RetailPage.AD_USER_ID + " ; ", connection);
                    NpgsqlDataReader _get__Ad_sequenc_no = cmd_select_sequenc_no.ExecuteReader();
                    connection.Close();
                }
                else
                {
                    return;
                }
            }
            else
            {
                return;
            }
            Console.WriteLine(RetailPage.AD_SessionID);
            RetailPage.Check_keyboard_Focus = "BarcodeSearch_cart_GotFocus";

            (this.Parent as Grid).Children.Remove(this);
        }