Пример #1
0
        public InvoiceAdd GetInvoiceAdd()
        {
            var result = new InvoiceAdd();

            result.CreatedDate        = InvoiceView.CreatedDate;
            result.DueDate            = InvoiceView.DueDate;
            result.EmailTo            = InvoiceView.EmailTo;
            result.GrandTotal         = InvoiceView.GrandTotal;
            result.InvoiceEmailed     = InvoiceView.InvoiceEmailed;
            result.InvoiceId          = InvoiceView.InvoiceId;
            result.InvoiceNo          = InvoiceView.InvoiceNo;
            result.Notes              = InvoiceView.Notes;
            result.OrderedBy          = InvoiceView.OrderedBy;
            result.PaidAmount         = InvoiceView.PaidAmount;
            result.PaidDate           = InvoiceView.PaidDate;
            result.PaidTax            = InvoiceView.PaidTax;
            result.PaymentDetails     = InvoiceView.PaymentDetails;
            result.PurchaseOrderRef   = InvoiceView.PurchaseOrderRef;
            result.Status             = InvoiceView.Status;
            result.SubTotal           = InvoiceView.SubTotal;
            result.TaxTotal           = InvoiceView.TaxTotal;
            result.TermsAndConditions = InvoiceView.TermsAndConditions;
            result.CustomerCustomerId = InvoiceView.CustomerCustomerId;
            return(result);
        }
Пример #2
0
        private void btnAdd_Click_1(object sender, EventArgs e)
        {
            if (int.Parse(txtQuantity.Text) <= int.Parse(lblStockleft.Text))
            {
                InvoiceAdd inv = new InvoiceAdd();
                inv.Product_ID = Convert.ToInt32(cmbProductID.SelectedValue.ToString());
                inv.Quantity   = Convert.ToInt32(txtQuantity.Text);
                inv.Update(inv);
                DataBindToCombobox();


                int row;
                dataGridView1.Rows.Add();
                row = dataGridView1.Rows.Count - 1;
                dataGridView1[0, row].Value = int.Parse(cmbProductID.SelectedValue.ToString());
                dataGridView1[1, row].Value = cmbProductID.Text;
                dataGridView1[2, row].Value = Convert.ToInt32(txtPrice.Text);
                dataGridView1[3, row].Value = Convert.ToDecimal(txtQuantity.Text);
                dataGridView1[4, row].Value = Convert.ToDecimal(txtTotal.Text);
            }
            else
            {
                MessageBox.Show("Stock Out Of Bounce");
            }
        }
Пример #3
0
        public async Task <ActionResult <IInvoiceView> > Add([FromBody] InvoiceAdd invoiceCreate)
        {
            try
            {
                var grain  = _orleansService.Client.GetGrain <IInvoiceAddCommand>(0);
                var result = await grain.InvoiceAdd(invoiceCreate);

                if (result.__CQRSSuccessful)
                {
                    return(new ActionResult <IInvoiceView>(result));
                }
                else
                {
                    return(new ContentResult()
                    {
                        StatusCode = result.__CQRSStatusCode, Content = result.__CQRSErrorMessage, ContentType = "text/plain"
                    });
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLogger().Log(LogLevel.Error, e);
                return(new ContentResult()
                {
                    StatusCode = 500, Content = "Fatal API Error", ContentType = "text/plain"
                });
            }
        }
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var client = new ClientBuilder()
                             .UseLocalhostClustering()
                             .Configure <ClusterOptions>(options =>
                {
                    options.ClusterId = "dev";
                    options.ServiceId = "SilverdawnSoftwareInvoiceApp";
                })
                             .ConfigureLogging(logging => logging.AddConsole())
                             .Build();

                client.Connect(CreateRetryFilter()).Wait();


                var toAdd = new InvoiceAdd()
                {
                    TermsAndConditions = Guid.NewGuid().ToString()
                };
                var grain  = client.GetGrain <IInvoiceAddCommand>(0);
                var result = await grain.InvoiceAdd(toAdd);

                MessageBox.Show(result.__CQRSStatusCode.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public IHttpActionResult Post([FromBody] InvoiceAdd newItem)
        {
            // Ensure that the URI is clean (and does not have an id parameter)
            if (Request.GetRouteData().Values["id"] != null)
            {
                return(BadRequest("Invalid request URI"));
            }

            // Ensure that a "newItem" is in the entity body
            if (newItem == null)
            {
                return(BadRequest("Must send an entity body with the request"));
            }

            // Ensure that we can use the incoming data
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // Attempt to add the new object
            var addedItem = m.InvoiceAdd(newItem);

            // Continue?
            if (addedItem == null)
            {
                return(BadRequest("Cannot add the object"));
            }

            // HTTP 201 with the new object in the entity body
            // Notice how to create the URI for the Location header
            var uri = Url.Link("DefaultApi", new { id = addedItem.InvoiceId });

            return(Created(uri, addedItem));
        }
Пример #6
0
 public void Update(InvoiceAdd prdt)
 {
     using (MySqlConnection con = new MySqlConnection(LoginUser.cs))
     {
         string sql = "UPDATE `tbl_stock` SET `Quantity`= Quantity-'" + prdt.Quantity + "' WHERE `Product_ID`=" + prdt.Product_ID;
         con.Open();
         MySqlCommand cmd = new MySqlCommand(sql, con);
         cmd.ExecuteNonQuery();
     }
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var toAdd = new InvoiceAdd()
            {
                TermsAndConditions = Guid.NewGuid().ToString()
            };

            var http = new EasyHttp.Http.HttpClient();

            // http.Post("http://localhost:32772/api/Invoice", toAdd, HttpContentTypes.ApplicationJson);
            var response = http.Post("http://localhost:55526/api/Invoice", toAdd, HttpContentTypes.ApplicationJson);

            MessageBox.Show(response.StatusCode.ToString());
        }
Пример #8
0
        // Add Transaction Code
        public async Task <InvoiceView> Add(InvoiceAdd add)
        {
            try
            {
                using (var db = new data.InvoiceContext())
                {
                    var result = await Add(db, add);

                    await db.SaveChangesAsync();

                    return((InvoiceView)result);
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLogger().Log(LogLevel.Error, e);
                return(null);
            }
        }
        public async Task <InvoiceView> InvoiceAdd(InvoiceAdd add)
        {
            try
            {
                string json = "";

                var client = new HttpClient();

                using (var ms = new MemoryStream())
                {
                    var serializer = new DataContractJsonSerializer(typeof(InvoiceAdd));
                    serializer.WriteObject(ms, add);
                    ms.Position = 0;
                    StreamReader sr = new StreamReader(ms);
                    json = sr.ReadToEnd();
                }

                var stream = await client.PostAsync("http://localhost:44443/api/invoice", new StringContent(json, Encoding.UTF8, "application/json"));

                using (var ms = new MemoryStream())
                {
                    var serializer = new DataContractJsonSerializer(typeof(InvoiceView), new DataContractJsonSerializerSettings()
                    {
                        DateTimeFormat = new DateTimeFormat("yyyy-MM-dd'T'HH:mm:ss")
                    });
                    await stream.Content.CopyToAsync(ms);

                    ms.Position = 0;
                    var view = serializer.ReadObject(ms) as InvoiceView;
                    return(view);
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLogger().Log(LogLevel.Error, e);
                return(null);
            }
        }
Пример #10
0
        public async Task <data.Invoice> Add(data.InvoiceContext db, InvoiceAdd add)
        {
            try
            {
                var newInvoice = new data.Invoice();
                newInvoice.BillingAddress     = add.BillingAddress;
                newInvoice.CreatedDate        = add.CreatedDate;
                newInvoice.DueDate            = add.DueDate;
                newInvoice.EmailTo            = add.EmailTo;
                newInvoice.GrandTotal         = add.GrandTotal;
                newInvoice.InvoiceEmailed     = add.InvoiceEmailed;
                newInvoice.InvoiceNo          = add.InvoiceNo;
                newInvoice.Notes              = add.Notes;
                newInvoice.OrderedBy          = add.OrderedBy;
                newInvoice.PaidAmount         = add.PaidAmount;
                newInvoice.PaidDate           = add.PaidDate;
                newInvoice.PaidTax            = add.PaidTax;
                newInvoice.PaymentDetails     = add.PaymentDetails;
                newInvoice.PurchaseOrderRef   = add.PurchaseOrderRef;
                newInvoice.ShippingAddress    = add.ShippingAddress;
                newInvoice.SubTotal           = add.SubTotal;
                newInvoice.TaxTotal           = add.TaxTotal;
                newInvoice.TermsAndConditions = add.TermsAndConditions;
                var customerLookup = await db.Customers.FirstOrDefaultAsync(w => w.CustomerId == add.CustomerCustomerId);

                if (customerLookup != null)
                {
                    newInvoice.Customer = customerLookup;
                }
                db.Invoices.Add(newInvoice);
                return(newInvoice);
            }
            catch (Exception e)
            {
                LogFactory.GetLogger().Log(LogLevel.Error, e);
                return(null);
            }
        }
Пример #11
0
        public void geProductDetails(string inv)
        {
            InvoiceAdd invadd = new InvoiceAdd();

            using (MySqlConnection con = new MySqlConnection(LoginUser.cs))
            {
                string       sql = "SELECT * FROM `tbl_product` INNER JOIN tbl_stock ON tbl_stock.Product_ID =tbl_product.Product_ID WHERE tbl_product.Product_ID='" + Convert.ToInt32(inv) + "';";
                MySqlCommand cmd = new MySqlCommand(sql, con);
                con.Open();
                MySqlDataReader dr = cmd.ExecuteReader();


                if (dr.Read())
                {
                    txtPrice.Text     = Convert.ToString(dr["Price"]);
                    lblStockleft.Text = Convert.ToString(dr["Quantity"]);
                }
                else
                {
                    MessageBox.Show("fail");
                }
            }
        }