Exemple #1
0
        public static List <SalesDetail> GetOnlineSalesDetailDB()
        {
            List <SalesDetail> lst  = new List <SalesDetail>();
            SqlConnection      conn = new SqlConnection(connStaticString);
            SqlCommand         cmd  = new SqlCommand("sp_ClientSalesDetailOnline", conn);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@salesMasterID", GetLastMasterIDLocal());
            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read() && reader.HasRows)
            {
                SalesDetail salesDetail = new SalesDetail();
                salesDetail.ProductID          = Convert.ToInt64(reader["ProductID"]);
                salesDetail.ProductName        = reader["ProductName"].ToString();
                salesDetail.Quantity           = Convert.ToInt32(reader["Quantity"]);
                salesDetail.UnitPrice          = Convert.ToDecimal(reader["UnitPrice"]);
                salesDetail.TotalPrice         = Convert.ToDecimal(reader["TotalPrice"]);
                salesDetail.SalesMasterIDLocal = Convert.ToInt64(reader["SalesMaster_ID"]);
                lst.Add(salesDetail);
            }
            conn.Close();
            return(lst);
        }
        /// <summary>
        /// THIS CODE IS USED TO FETCH ALL THE SALE INVOICES OF EACH VENDOR WHOSE CONNECTIVITY WAS REPRESENTING THE STATUS
        /// OF BEING AS OFFLINE TO THE INTERNET AT THE TIME OF SOME SALE INVOICE ENTRY OPERATIONS
        /// </summary>
        ///
        /// <returns>A GENERIC LIST OF SALE INVOICES ARE RETURNED AT RUNTIME TO THE FUNCTION CALL</returns>
        public static List <SalesDetail> GetOfflineSalesDetail()
        {
            List <SalesDetail> lst  = new List <SalesDetail>();
            SqlConnection      conn = new SqlConnection(connStaticString);
            SqlCommand         cmd  = new SqlCommand("sp_KPRAInsertOfflineSalesDetails", conn);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                SalesDetail salesDetail = new SalesDetail();
                salesDetail.ProductID          = Convert.ToInt64(reader["ProductID"]);
                salesDetail.ProductName        = reader["ProductName"].ToString();
                salesDetail.Quantity           = Convert.ToInt64(reader["Quantity"]);
                salesDetail.UnitPrice          = Convert.ToDecimal(reader["UnitPrice"]);
                salesDetail.TotalPrice         = Convert.ToDecimal(reader["TotalPrice"]);
                salesDetail.SalesMasterIDLocal = Convert.ToInt64(reader["SalesMaster_ID"]);
                salesDetail.BusinessIDLocal    = Convert.ToInt64(reader["business_ID"]);
                salesDetail.BusinessCode       = reader["BusinessCode"].ToString();

                lst.Add(salesDetail);
            }

            conn.Close();
            return(lst.ToList());
        }
Exemple #3
0
        public HttpResponseMessage SalesDetail([FromBody] KPRA_RIMS.Classes.SalesDetail salesDetail)
        {
            SqlConnection connection = new SqlConnection(this.connString);

            try
            {
                SqlCommand stateObject = new SqlCommand("sp_InsertSalesDetailsKPRA", connection)
                {
                    CommandType = CommandType.StoredProcedure
                };
                stateObject.Parameters.AddWithValue("@ProductID", salesDetail.ProductID);
                stateObject.Parameters.AddWithValue("@ProductName", salesDetail.ProductName);
                stateObject.Parameters.AddWithValue("@Quantity", salesDetail.Quantity);
                stateObject.Parameters.AddWithValue("@UnitPrice", salesDetail.UnitPrice);
                stateObject.Parameters.AddWithValue("@TotalPrice", salesDetail.TotalPrice);
                stateObject.Parameters.AddWithValue("@SalesMaster_Id", salesDetail.SalesMasterIDLocal);
                stateObject.Parameters.AddWithValue("@businessIDLocal", salesDetail.BusinessIDLocal);
                stateObject.Parameters.AddWithValue("@businessCode", salesDetail.BusinessCode);
                connection.Open();
                IAsyncResult result = stateObject.BeginExecuteNonQuery(new AsyncCallback(AsynchSql.CallBack), stateObject);
                while (!result.IsCompleted)
                {
                    this.resp = base.Request.CreateResponse <KPRA_RIMS.Classes.SalesDetail>(HttpStatusCode.Created, salesDetail);
                }
            }
            catch (SqlException)
            {
            }
            catch (Exception)
            {
            }
            finally
            {
                if (connection != null)
                {
                    connection.Dispose();
                }
            }
            return(this.resp);
        }
Exemple #4
0
        /// <summary>
        /// BY TRANSFERRING REALTIME VOUCHERS AND SALE INVOICES IS PREREQUISITE TO EVERY SERVER-SIDE RIMS APPLICATION.
        /// THIS DETAILED SALE INVOICE IS USED TO TRANSFER INVOICING DATA TO THE RELEVANT SERVER BY ONE BUTTON CLICK.
        /// </summary>
        /// <param name="totalAmount">THIS PARAM REPRESENTS THE TOTAL AMOUNT OF INVOICE CREATED</param>
        /// <param name="discount">THIS PARAM REPRESENTS DISCOUNT RATES OFFERED TO CUSTOMERS</param>
        /// <param name="salesTaxRate">THIS PARAM REPRESENTS SALES TAX RATE</param>
        /// <param name="salesTax">THIS PARAM REPRESENTS SALES TAX ON SERVICES AS PER TOTAL SUM OF INVOICE</param>
        /// <param name="netAmount">THIS PARAM REPRESENTS NET AMOUNT OF THE INVOICE CREATED</param>
        /// <param name="paid">THIS PARAM REPRESENTS MONEY PAID BY THE CUSTOMER</param>
        /// <param name="todayTime">THIS PARAM REPRESENTS CURRENT DATE AND TIME OF INVOICE CREATED ON</param>
        /// <param name="businessID">THIS PARAM REPRESENTS BUSINESS ID OF PER BUSINESS FIRM OR COMPANY</param>
        /// <param name="stationID">THIS PARAM REPRESENTS STATION IDENTIFIER OF EACH STATION LINKED WITH A PARTICULAR BUSINESS FIRM OR COMPANY </param>
        /// <param name="description">THIS PARAM REPRESENTS THE EXPLAINATION OF THE INVOICE</param>
        /// <param name="otherCharges">THIS PARAM REPRESENTS MISCELLANEOUS CHARGES RENDERD</param>
        public static void SendOnlineSalesDetail(long productID, string productName, int quantity,
                                                 decimal unitPrice, decimal totalPrice, long salesMasterIDLocal, long businessIDLocal, string businessCode)
        {
            string results;
            string connectionError = "";

            try
            {
                SalesDetail salesDetail = new SalesDetail();
                salesDetail.ProductID          = productID;
                salesDetail.ProductName        = productName;
                salesDetail.Quantity           = quantity;
                salesDetail.UnitPrice          = unitPrice;
                salesDetail.TotalPrice         = totalPrice;
                salesDetail.SalesMasterIDLocal = salesMasterIDLocal;
                salesDetail.BusinessIDLocal    = businessIDLocal;
                salesDetail.BusinessCode       = businessCode;

                //using (var client = new HttpClient())
                //{
                HttpClient client = new HttpClient();
                client = BusinessAuthentication.SendAuthentication();
                string      apiUrl       = ConfigurationManager.AppSettings["api_url"] + "sales";
                string      inputJson    = (new JavaScriptSerializer()).Serialize(salesDetail);
                HttpContent inputContent = new StringContent(inputJson, Encoding.UTF8, "application/json");
                try
                {
                    HttpResponseMessage response = client.PostAsync(apiUrl + "/SalesDetail", inputContent).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        results = response.Content.ReadAsStringAsync().Result.ToString();
                        SqlConnection conn = new SqlConnection(connStaticString);
                        SqlCommand    cmd  = new SqlCommand("sp_InvertClientUpdateConnectionStateFromOneToNullInSales_Details", conn);
                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                    else
                    {
                        //update isconnected value to 0 in sales_details table where isConnected is equal to 1 recently
                        SqlConnection conn = new SqlConnection(connStaticString);
                        SqlCommand    cmd  = new SqlCommand("sp_InvertClientUpdateConnectionStatusInSales_Details", conn);
                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                }
                catch (Exception ex)
                {
                    SqlConnection conn = new SqlConnection(connStaticString);
                    SqlCommand    cmd  = new SqlCommand("sp_InvertClientUpdateConnectionStatusInSales_Details", conn);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }



                //}
            }
            catch {
                SqlConnection conn = new SqlConnection(connStaticString);
                SqlCommand    cmd  = new SqlCommand("sp_InvertClientUpdateConnectionStatusInSales_Details", conn);
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
            }
        }
        /// <summary>
        /// THIS METHOD IS A STATIC ONE, IS USED TO SEND OFFLINE INVOICES ON WINDOWS FORM ACTIVATED METHOD WHENEVER THE CONNECTION GETS ONLINE
        /// THE EVENT IS INVOKED AND RESUMES THE PROCESS OF SENDING OFFLINE INVOICES FROM THE LOCAL MACHINE TO THE SERVER SITE
        ///
        /// </summary>
        public static string SendVendorOfflineSalesDetail()
        {
            string read            = "";
            string connectionError = "";

            try
            {
                HttpClient client = new HttpClient();
                client = BusinessAuthentication.SendAuthentication();
                string      apiUrl       = ConfigurationManager.AppSettings["api_url"] + "sales";
                string      inputJson    = (new JavaScriptSerializer()).Serialize(OfflineActivities.GetOfflineSalesDetail());
                HttpContent inputContent = new StringContent(inputJson, Encoding.UTF8, "application/json");

                HttpResponseMessage response = client.PostAsync(apiUrl + "/SalesDetailOfflineInvoice", inputContent).Result;

                if (response.IsSuccessStatusCode)
                {
                    SalesDetail sales    = new SalesDetail();
                    var         readTask = response.Content.ReadAsAsync <List <SalesDetail> >().Status;
                    read = readTask.ToString();
                    SqlConnection conn = new SqlConnection(connStaticString);
                    SqlCommand    cmd  = new SqlCommand("sp_ClientConnectionStatusInOfflineActivityToNullInSales_Details", conn);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
                else
                {
                }
            }
            catch (SocketException ex)
            {
                string s = ex.ToString();
                //return false;
            }
            //catch (System.Net.Sockets.SocketException socketEx)
            //{
            //    read += socketEx.Message + "\r\n" + socketEx.StackTrace;
            //}
            catch (System.Net.WebException socketEx)
            {
                read += socketEx.Message + "\r\n" + socketEx.StackTrace;
            }
            catch (AggregateException ex)
            {
                foreach (Exception inner in ex.InnerExceptions)
                {
                    Console.WriteLine("Exception type {0} from {1}", inner.GetType(), inner.Source);
                    read += inner.GetType() + " " + inner.Source;
                }
            }

            ////catch (SystemException sysEx)
            ////{ }
            ////catch (Exception ex)
            ////{ }
            //catch (System.Net.Sockets.SocketException socketEx)
            //{
            //    read += socketEx.Message + "\r\n";
            //}
            //catch (System.Net.WebException socketEx)
            //{
            //    read += socketEx.Message + "\r\n";
            //}

            return(read);
        }