protected void sellButton_Click(object sender, EventArgs e)
        {
            //int companyId = Convert.ToInt32(companyDropDownList.SelectedValue);
            //int itemId = Convert.ToInt32(itemDropDownList.SelectedValue);
            //string quantity = stockOutQuantityTextBox.Text;
            //Item item = new Item(itemId, companyId, quantity);
            //StockOutQuantitySell(item);
            //BindAllCompany();

            //BindAllItem(itemId);
            List <Stockout> stockouts = new List <Stockout>();

            foreach (GridViewRow row in stockOutGridView.Rows)
            {
                Stockout stockout    = new Stockout();
                string   itemName    = row.Cells[0].Text;
                string   companyName = row.Cells[1].Text;
                string   Quantity    = row.Cells[2].Text;
                stockout.ItemName    = itemName;
                stockout.CompanyName = companyName;
                stockout.Quantity    = Quantity;
                stockouts.Add(stockout);
            }
            StockManager stockManager = new StockManager();

            stockManager.StockOutQuantity(stockouts);
        }
 public int Put([FromBody] Stockout m)
 {
     System.Random rdn = new System.Random();
     m.OrderNo    = Convert.ToInt32(rdn.Next(99999999).ToString().PadLeft(8, '0'));
     m.CreateDate = DateTime.Now;
     return(dal.Upt(m));
 }
        public List <Stockout> SellOrderList()
        {
            string query1 = @"SELECT [Id] FROM [dbo].[tb_StockOut] Where Status = '" + "Ordered" + "'";

            try
            {
                SqlCommand command = new SqlCommand(query1, _connection);
                _connection.Open();
                SqlDataReader   reader    = command.ExecuteReader();
                List <Stockout> stockouts = new List <Stockout>();
                while (reader.Read())
                {
                    Stockout stockout = new Stockout();
                    stockout.Id = (int)reader["Id"];
                    stockouts.Add(stockout);
                }
                reader.Close();
                return(stockouts);
            }
            catch (Exception exception)
            {
                throw new Exception("Unable to connect Server", exception);
            }
            finally
            {
                _connection.Close();
            }
        }
        public string ConfirmSellOrder(Stockout stockout)
        {
            if (_stockOut.ConfirmSellOrder(stockout) > 0)
            {
                return("Aprove Sell Ordered");
            }

            return("Oparetion Faild");
        }
Example #5
0
        public ActionResult Stockout(Stockout stockout)
        {
            stockout.Status = "Ok";
            ViewBag.msg     = _stockOut.ConfirmSellOrder(stockout);

            ViewBag.orderId = _stockOut.SellOrderList();

            return(View());
        }
        public HttpResponseMessage PostStockout(Stockout stockout)
        {
            var messages = _stockOut.ConfirmSellOrder(stockout);

            if (messages != null)
            {
                var message = Request.CreateResponse(HttpStatusCode.Created, messages);
                return(message);
            }
            return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Category not created"));
        }
        public ActionResult Stockout(Stockout stockout)
        {
            stockout.Status = "Ok";

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://fmcg.somee.com");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                var response = client.PostAsJsonAsync("api/StockOut/PostStockout", stockout).Result;

                if (response.IsSuccessStatusCode)
                {
                    string msg     = response.Content.ReadAsStringAsync().Result;
                    var    records = JsonConvert.DeserializeObject(msg); //  JSON.Net
                    ViewBag.msg = records;
                }
            }

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://fmcg.somee.com");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = client.GetAsync("api/StockOut/").Result;
                string res = "";
                using (HttpContent content = response.Content)
                {
                    // ... Read the string.
                    Task <string> result = content.ReadAsStringAsync();
                    res = result.Result;

                    var records = JsonConvert.DeserializeObject <List <Stockout> >(res); //  JSON.Net

                    foreach (Stockout record in records)
                    {
                        var category = (string.Format("Id: {0}", record.Id));
                    }

                    ViewBag.orderId = records;
                }
            }

            return(View());
        }
        protected void damageButton_Click(object sender, EventArgs e)
        {
            List <Stockout> stockouts = new List <Stockout>();

            foreach (GridViewRow row in stockOutGridView.Rows)
            {
                Stockout stockout    = new Stockout();
                string   itemName    = row.Cells[0].Text;
                string   companyName = row.Cells[1].Text;
                string   Quantity    = row.Cells[2].Text;
                stockout.ItemName    = itemName;
                stockout.CompanyName = companyName;
                stockout.Quantity    = Quantity;
                stockouts.Add(stockout);
            }
            StockManager stockManager = new StockManager();

            stockManager.StockOutQuantity(stockouts);
        }
        public int ConfirmSellOrder(Stockout stockout)
        {
            string query = @"UPDATE [dbo].[tb_StockOut] SET [Status] = '" + stockout.Status + "'WHERE Id = '" +
                           stockout.Id + "'";

            try
            {
                SqlCommand command = new SqlCommand(query, _connection);
                _connection.Open();
                int rowAffected = command.ExecuteNonQuery();
                _connection.Close();

                return(rowAffected);
            }
            catch (Exception exception)
            {
                throw new Exception("Unable to connect Server", exception);
            }
            finally
            {
                _connection.Close();
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string   company     = ddlCompany.SelectedValue;
            string   item        = ddlItems.SelectedValue;
            int      reorder     = Convert.ToInt32(txtreorder.Text);
            int      quantity    = Convert.ToInt32(txtQuantity.Text);
            int      stockout    = Convert.ToInt32(txtStocOut.Text);
            int      total_stock = quantity - stockout;
            Stockout aStock      = new Stockout();

            aStock.Company  = company;
            aStock.Item     = item;
            aStock.Reorder  = reorder;
            aStock.Quantity = total_stock;
            string msg = aStockManager.SaveStock(aStock);

            lblmsg.Text = msg;
            clear();
            Binddata();
            btnSell.Visible   = true;
            btnDamage.Visible = true;
            btnLost.Visible   = true;
        }
Example #11
0
        private void AddStockout()
        {
            ProductInfo  dataById = Product.GetDataById(WebUtils.GetFormInt("pid"));
            StockoutInfo last     = Stockout.GetLast(WebUtils.GetFormInt("pid"));

            if (dataById == null)
            {
                base.WriteJsonTip(false, "商品不存在或者已删除", "");
            }
            else if (base.UserID == -1)
            {
                base.WriteJsonTip(false, "会员没有登录", "");
            }
            else if (last != null && System.DateTime.Now < last.AutoTimeStamp.AddDays(3.0))
            {
                base.WriteJsonTip(false, "3天内已经登记过了", "");
            }
            else
            {
                StockoutInfo entity = new StockoutInfo
                {
                    ProID         = dataById.AutoID,
                    ProName       = dataById.ProductName,
                    UserName      = base.UserName,
                    CurrStock     = dataById.Stock,
                    AutoTimeStamp = System.DateTime.Now
                };
                if (Stockout.Add(entity) > 0)
                {
                    base.WriteJsonTip(true, "登记成功,我们将尽快处理!", "");
                }
                else
                {
                    base.WriteJsonTip(false, "Thao tác thất bại!", "");
                }
            }
        }
Example #12
0
        public static void RefreshAMCValues(int storeId, Dictionary <int, long> items, int unitId)
        {
            var context     = new StockoutEntities();
            var genaralinfo = context.GenralInfos.First();
            var endDate     = DateTime.Now;
            var startDate   = endDate.Subtract(TimeSpan.FromDays(genaralinfo.AMCRange * 30));

            try
            {
                foreach (var row in items)
                {
                    if (row.Value == 0)
                    {
                        var stockOut = new Stockout()
                        {
                            ItemID          = row.Key,
                            StoreID         = storeId,
                            StartDate       = DateTime.Now,
                            EndDate         = null,
                            LastIndexedTime = DateTime.Now
                        };
                        context.Stockouts.Add(stockOut);
                        context.SaveChanges();
                    }

                    var allItemIds = context.AmcReports.SingleOrDefault(m => m.ItemID == row.Key && m.StoreID == storeId && m.UnitID == unitId);
                    if (allItemIds == null)
                    {
                        var amcreport = new AmcReport
                        {
                            ItemID          = row.Key,
                            StoreID         = storeId,
                            AmcRange        = genaralinfo.AMCRange,
                            IssueInAmcRange =
                                CalculateTotalConsumptionWithoutDOS(row.Key, storeId, startDate,
                                                                    DateTime.Today),
                            DaysOutOfStock =
                                CalculateStockoutDays(row.Key, storeId, startDate, endDate),
                            AmcWithDOS =
                                CalculateAverageConsumption(row.Key, storeId, startDate, endDate, CalculationOptions.Monthly),
                            AmcWithOutDOS   = CalculateTotalConsumptionWithoutDOS(row.Key, storeId, startDate, endDate) / Convert.ToDouble(genaralinfo.AMCRange),
                            LastIndexedTime = DateTime.Now,
                            IssueWithDOS    = Builder.CalculateTotalConsumption(row.Key, storeId, startDate, DateTime.Now),
                            UnitID          = unitId
                        };
                        context.AmcReports.Add(amcreport);
                    }
                    // Update AMC value
                    else
                    {
                        allItemIds.IssueInAmcRange = CalculateTotalConsumptionWithoutDOS(row.Key, storeId, startDate,
                                                                                         DateTime.Now);
                        allItemIds.DaysOutOfStock  = CalculateStockoutDays(row.Key, storeId, startDate, DateTime.Now);
                        allItemIds.AmcWithDOS      = CalculateAverageConsumption(row.Key, storeId, startDate, endDate, CalculationOptions.Monthly);
                        allItemIds.AmcWithOutDOS   = CalculateTotalConsumptionWithoutDOS(row.Key, storeId, startDate, endDate) / Convert.ToDouble(genaralinfo.AMCRange);
                        allItemIds.IssueWithDOS    = Builder.CalculateTotalConsumption(row.Key, storeId, startDate, DateTime.Now);
                        allItemIds.LastIndexedTime = DateTime.Now;
                        allItemIds.UnitID          = unitId;
                    }

                    context.SaveChanges();
                }
            }
            catch (DbUpdateException ex)
            {
                throw;
            }
        }
Example #13
0
        public static List <Stockout> GetStockOutHistory(int itemID, int storeID)
        {
            var allTransactions = TransactionDates(itemID, storeID).OrderBy(m => m.Date).ToArray();
            var receipts        = ReceiptsByItem(itemID, storeID).OrderBy(m => m.Date);
            var issues          = IssuesByItem(itemID, storeID).OrderBy(m => m.Date);
            var disposals       = DisposalsByItem(itemID, storeID).OrderBy(m => m.Date);
            var adjustments     = AdjustmentsByItem(itemID, storeID).OrderBy(m => m.Date);

            var receiptsInnerJoin = (from transactionDate in allTransactions
                                     join receipt in receipts
                                     on new { transactionDate.TransactionID, transactionDate.Date, transactionDate.TransactionType } equals new { receipt.TransactionID, receipt.Date, receipt.TransactionType }
                                     into temp
                                     from receipt in temp.DefaultIfEmpty()
                                     select new Transaction
            {
                TransactionType = transactionDate.TransactionType,
                Date = transactionDate.Date,
                Quantity = receipt == null ? null : receipt.Quantity
            }).ToArray();

            var issuesInnerJoin = (from transactionDate in allTransactions
                                   join issue in issues
                                   on new { transactionDate.TransactionID, transactionDate.Date, transactionDate.TransactionType } equals new { issue.TransactionID, issue.Date, issue.TransactionType }
                                   into temp
                                   from issue in temp.DefaultIfEmpty()
                                   select new Transaction
            {
                TransactionType = transactionDate.TransactionType,
                Date = transactionDate.Date,
                Quantity = issue == null ? null : issue.Quantity
            }).ToArray();

            var disposalsInnerJoin = (from transactionDate in allTransactions
                                      join disposal in disposals
                                      on new { transactionDate.TransactionID, transactionDate.Date, transactionDate.TransactionType } equals new { disposal.TransactionID, disposal.Date, disposal.TransactionType }
                                      into temp
                                      from disposal in temp.DefaultIfEmpty()
                                      select new Transaction
            {
                TransactionType = transactionDate.TransactionType,
                Date = transactionDate.Date,
                Quantity = disposal == null ? null : disposal.Quantity
            }).ToArray();
            var adjustmentsInnerJoin = (from transactionDate in allTransactions
                                        join adjustment in adjustments
                                        on new { transactionDate.TransactionID, transactionDate.Date, transactionDate.TransactionType } equals new { adjustment.TransactionID, adjustment.Date, adjustment.TransactionType }
                                        into temp
                                        from adjustment in temp.DefaultIfEmpty()
                                        select new Transaction
            {
                TransactionType = transactionDate.TransactionType,
                Date = transactionDate.Date,
                Quantity = adjustment == null ? null : adjustment.Quantity
            }).ToArray();
            var  stockOuts = new List <Stockout>();
            long?balance   = 0;
            var  stockOut  = new Stockout()
            {
                ItemID = itemID, StoreID = storeID
            };
            var lastTransaction = allTransactions.LastOrDefault();

            for (int i = 0; i < allTransactions.Length; i++)
            {
                switch (allTransactions[i].TransactionType)
                {
                case TransactionType.Receipt:
                    if (allTransactions[i].TransactionType != receiptsInnerJoin[i].TransactionType)
                    {
                        throw new Exception("Algorithm Error.");
                    }
                    if (balance == 0 && stockOut.StartDate != DateTime.Parse("1/1/0001"))
                    {
                        stockOut.EndDate = allTransactions[i].Date.Value;
                        stockOuts.Add(stockOut);
                        stockOut = new Stockout()
                        {
                            ItemID = itemID, StoreID = storeID
                        };
                    }
                    balance += receiptsInnerJoin[i].Quantity;
                    break;

                case TransactionType.Issue:
                    if (allTransactions[i].TransactionType != issuesInnerJoin[i].TransactionType)
                    {
                        throw new Exception("Algorithm Error!");
                    }
                    balance -= issuesInnerJoin[i].Quantity;
                    if (balance <= 0 && stockOut.StartDate != DateTime.Parse("1/1/0001"))
                    {
                        stockOut.StartDate = allTransactions[i].Date.Value;
                        balance            = 0;
                    }

                    break;

                case TransactionType.Disposal:
                    if (allTransactions[i].TransactionType != disposalsInnerJoin[i].TransactionType)
                    {
                        throw new Exception("Algorithm Error!");
                    }
                    balance -= disposalsInnerJoin[i].Quantity;
                    if (balance <= 0)
                    {
                        stockOut.StartDate = allTransactions[i].Date.Value;
                        balance            = 0;
                    }
                    break;

                case TransactionType.Adjustment:
                    if (allTransactions[i].TransactionType != adjustmentsInnerJoin[i].TransactionType)
                    {
                        throw new Exception("Algorithm Error!");
                    }
                    if (balance == 0 && stockOut.StartDate != DateTime.Parse("1/1/0001"))
                    {
                        stockOut.EndDate = allTransactions[i].Date.Value;
                        stockOuts.Add(stockOut);
                        stockOut = new Stockout()
                        {
                            ItemID = itemID, StoreID = storeID
                        };
                    }
                    balance += adjustmentsInnerJoin[i].Quantity;
                    break;

                default:
                    break;
                }
            }
            if (stockOut.StartDate != DateTime.Parse("1/1/0001") && !stockOut.EndDate.HasValue)
            {
                stockOut.EndDate = DateTime.Today;
                stockOuts.Add(stockOut);
            }
            return(stockOuts);
        }
        public IHttpActionResult PostProductForBill1([FromBody] FormCollection frm, [FromUri] FormDataCollection frm1)
        {
            bool status = false;

            Billing_Master        billing = new Billing_Master();
            List <Billing_Detail> detail  = new List <Billing_Detail>();
            Billing_Detail        blldtl  = new Billing_Detail();
            Stockout        stkout        = new Stockout();
            List <Stockout> stkoutlst     = new List <Stockout>();

            Barcode_Master brcdmstr = new Barcode_Master();

            if (!ModelState.IsValid)
            {
                return(BadRequest("Sorry there is some problem. Please check and try again"));
            }

            using (EasyBillingEntities dc = new EasyBillingEntities())
            {
                var    text        = dc.Billing_Masters.OrderByDescending(x => x.Billing_Number).Select(x => x.Billing_Number).Distinct().FirstOrDefault();
                var    fstfr       = text.Substring(0, 3);
                var    lstfr       = text.Substring(text.Length - 8);
                string newlstversn = (int.Parse(lstfr) + 100000001).ToString();
                string fstfr1      = (newlstversn.Substring(newlstversn.Length - 8)).ToString();
                String totalvrsn   = fstfr + fstfr1;
                billing.Billing_Number = totalvrsn;

                var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

                Random rd = new Random();

                var chars1 = Enumerable.Range(0, 14)
                             .Select(x => chars[rd.Next(0, chars.Length)]);
                string barcode = new string(chars1.ToArray());

                billing.Token_Number = (Guid.NewGuid()).ToString();
                billing.Date         = DateTime.Now.Date;
                var mrchnttk = (from tkn in dc.Marchent_Accounts
                                where tkn.Email_Id == User.Identity.Name
                                select tkn.Token_number).Distinct().FirstOrDefault();
                billing.Marchent_Token_number = mrchnttk;
                var chkst = (from tkn in dc.Marchent_Accounts
                             join st in dc.States on tkn.State_Code equals st.State_Code
                             where tkn.Email_Id == User.Identity.Name
                             select new { st.SGST, st.CGST, st.IGST, st.UTGST }).Distinct().FirstOrDefault();

                billing.Total_tax          = decimal.Parse("0.00");
                billing.Rate_including_tax = decimal.Parse("0.00");
                billing.Discount_percent   = decimal.Parse("0.00");
                billing.Total_discount     = decimal.Parse("0.00");
                billing.Total_amount       = decimal.Parse("0.00");
                billing.CGST = decimal.Parse("0.00");
                billing.SGST = decimal.Parse("0.00");

                int b = 1;
                int l = 0;

                foreach (var key in frm.Keys)
                {
                    if (l % 2 == 0)
                    {
                        var k = key.ToString();

                        int a = int.Parse(k.Substring(k.Length - 1, 1));
                        if (a == b)
                        {
                        }
                        else
                        {
                            b = a;
                        }
                        var Token  = frm[a - 1];
                        var Sellon = frm[a];
                        var Quant  = int.Parse(frm[a + 1]);

                        var stockitems          = dc.Stocks.Where(x => x.Product_Token == Token).Distinct().FirstOrDefault();
                        var productforsaleitems = dc.Products_For_Sales.Where(x => x.Token_Number == Token).Distinct().FirstOrDefault();


                        if (stockitems != null)
                        {
                            stockitems.Pieces = stockitems.Pieces - (productforsaleitems.Pieces * Quant);

                            stockitems.Date = DateTime.Now.Date;

                            if (stockitems.Pieces < 0)
                            {
                                ModelState.AddModelError(string.Empty, "Please check your quantity");
                            }
                            else
                            {
                                dc.SaveChanges();
                            }
                        }

                        billing.Rate_including_tax = billing.Rate_including_tax + productforsaleitems.Amout_after_tax;
                        billing.Total_discount     = billing.Total_discount;
                        billing.Total_amount       = billing.Total_amount + productforsaleitems.Total;
                        billing.Total_tax          = billing.Total_tax + (productforsaleitems.Amout_after_tax - productforsaleitems.Selling_Price);

                        blldtl.Billing_Token_number = billing.Token_Number;
                        blldtl.Billing_number       = billing.Billing_Number;
                        blldtl.Date          = billing.Date;
                        blldtl.Product_Token = Token;
                        blldtl.Pieces        = productforsaleitems.Pieces * Quant;

                        blldtl.Amount           = productforsaleitems.Selling_Price;
                        blldtl.Taxable_amount   = productforsaleitems.Pieces * productforsaleitems.Selling_Price;
                        blldtl.Tax              = productforsaleitems.Amout_after_tax - productforsaleitems.Selling_Price;
                        blldtl.Discount         = decimal.Parse("0.00");
                        blldtl.Discount_percent = ((productforsaleitems.Amout_after_tax - productforsaleitems.Total) * 100) / productforsaleitems.Amout_after_tax;
                        blldtl.Sub_Total        = productforsaleitems.Total;

                        stkout.Billing_Token_number = billing.Token_Number;
                        stkout.Billing_number       = billing.Billing_Number;
                        stkout.Date          = billing.Date;
                        stkout.Product_Token = Token;
                        stkout.Pieces        = productforsaleitems.Pieces * Quant;

                        stkout.CGST                  = (productforsaleitems.Selling_Price * Quant) + ((productforsaleitems.CGST * Quant) / 100);
                        stkout.SGST                  = (productforsaleitems.Selling_Price * Quant) + ((productforsaleitems.SGST * Quant) / 100);
                        stkout.Sub_Total             = productforsaleitems.Total;
                        stkout.Marchent_Token_number = mrchnttk;

                        detail.Add(blldtl);
                        stkoutlst.Add(stkout);
                    }
                    l++;
                }
                if (chkst.SGST == true && chkst.CGST == true)
                {
                    billing.CGST = billing.Total_tax / 2;
                    billing.SGST = billing.CGST;
                }
                else if (chkst.CGST == true && chkst.IGST == true)
                {
                    billing.CGST = billing.Total_tax / 2;
                }
                else if (chkst.CGST == true && chkst.UTGST == true)
                {
                    billing.CGST = billing.Total_tax / 2;
                }
                else if (chkst.SGST == true && chkst.IGST == true)
                {
                    billing.SGST = billing.Total_tax / 2;
                }
                else if (chkst.SGST == true && chkst.UTGST == true)
                {
                    billing.SGST = billing.Total_tax / 2;
                }

                else
                {
                }

                brcdmstr.Barcode_Number       = barcode;
                brcdmstr.Billing_Number       = billing.Billing_Number;
                brcdmstr.Billing_Token_number = billing.Token_Number;
                brcdmstr.Date = billing.Date;

                billing.Barcode_Number = barcode;

                // image save for barcode///

                using (MemoryStream ms = new MemoryStream())
                {
                    //The Image is drawn based on length of Barcode text.
                    using (Bitmap bitMap = new Bitmap(barcode.Length * 30, 90))
                    {
                        //The Graphics library object is generated for the Image.
                        using (Graphics graphics = Graphics.FromImage(bitMap))
                        {
                            //The installed Barcode font.
                            Font   oFont = new Font("IDAutomationHC39M", 17);
                            PointF point = new PointF(2f, 2f);

                            //White Brush is used to fill the Image with white color.
                            SolidBrush whiteBrush = new SolidBrush(Color.White);
                            graphics.FillRectangle(whiteBrush, 0, 0, bitMap.Width, bitMap.Height);

                            //Black Brush is used to draw the Barcode over the Image.
                            SolidBrush blackBrush = new SolidBrush(Color.Black);
                            graphics.DrawString("*" + barcode + "*", oFont, blackBrush, point);
                        }

                        //The Bitmap is saved to Memory Stream.
                        bitMap.Save(ms, ImageFormat.Png);

                        //The Image is finally converted to Base64 string.


                        byte[] imageBytes = Convert.FromBase64String(Convert.ToBase64String(ms.ToArray()));

                        MemoryStream ms1 = new MemoryStream(imageBytes, 0, imageBytes.Length);
                        ms1.Write(imageBytes, 0, imageBytes.Length);

                        System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);
                        string spath = System.Web.HttpContext.Current.Server.MapPath("~/BillBarcode");
                        string path  = spath + "/" + billing.Billing_Number + ".jpg";
                        image.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);

                        //p.photo = imageBytes;
                        billing.Barcode_photo = imageBytes;
                        brcdmstr.Image        = imageBytes;
                    }
                }
                billing.Billing_Details = detail;
                billing.Stockouts       = stkoutlst;
                billing.Barcode_Master.Add(brcdmstr);

                dc.Billing_Masters.Add(billing);
                dc.SaveChanges();
                status = true;
            }

            return(Ok());
        }
Example #15
0
 public void Add(Stockout stockout)
 {
     Context.Stockouts.Add(stockout);
     Context.SaveChanges();
 }
Example #16
0
 public static UInt32 Insert(Stockout som)
 {
     return(HelperDal <Stockout> .Insert(som, "SELECT * FROM stockout WHERE som_id=0"));
 }
Example #17
0
 public void Update(Stockout stockout)
 {
     Context.Entry(stockout).State = EntityState.Modified;
     Context.SaveChanges();
 }
Example #18
0
 public void Delete(Stockout stockout)
 {
     this.Remove(stockout);
     Context.SaveChanges();
 }
Example #19
0
 void Remove(Stockout stockout)
 {
     Context.Stockouts.Remove(stockout);
 }
Example #20
0
 public static bool Update(Stockout som)
 {
     return(HelperDal <Stockout> .Update(som, "SELECT * FROM stockout WHERE som_id=" + som.som_id));
 }
Example #21
0
        //修改
        public int Upt(Stockout m)
        {
            string sql = string.Format("update Stockout set OrderNo='{0}',StockOutType='{1}',CustomerId='{2}',Remark='{3}',CreateBy='{4}',CreateDate='{5}',ModifiedBy='{6}',ModifiedDate='{7}' where StockOutId={8}", m.OrderNo, m.StockOutType, m.CustomerId, m.Remark, m.CreateBy, m.CreateDate, m.ModifiedBy, m.ModifiedDate, m.StockOutId);

            return(DBHelper.ExecuteNonQuery(sql));
        }
        public ActionResult PendingShipping(int?page, string id, string sccess, string bllno)
        {
            PendingShipping        pendingShipping     = new PendingShipping();
            List <PendingShipping> pendingShippingList = new List <PendingShipping>();

            using (EasyBillingEntities db = new EasyBillingEntities())
            {
                List <Placed_Order> placed_Order = db.Placed_Orders.Where(z => z.Orderplaced == false).Distinct().ToList();
                if (id != null)
                {
                    Placed_Order plcdorder = db.Placed_Orders.Where(z => z.Token_number == id).Distinct().FirstOrDefault();
                    if (plcdorder.Orderplaced == false)
                    {
                        plcdorder.Orderplaced  = true;
                        plcdorder.Approve_Date = DateTime.Now.Date;
                        db.SaveChanges();
                        Billing_Master billing        = new Billing_Master();
                        Billing_Detail billing_Detail = new Billing_Detail();
                        Stockout       stockout       = new Stockout();

                        Products_For_Sale products_For_Sale = db.Products_For_Sales.Where(z => z.Token_Number == plcdorder.Item_token).FirstOrDefault();
                        //===============bill master entry=========================//
                        billing.Customer_Token_number = plcdorder.Customer_token;
                        billing.Total_tax             = (products_For_Sale.Amout_after_tax - products_For_Sale.Selling_Price) * plcdorder.Pieces;
                        billing.Rate_including_tax    = (products_For_Sale.Amout_after_tax) * plcdorder.Pieces;
                        billing.Total_discount        = decimal.Parse("0.00") * plcdorder.Pieces;
                        billing.Total_amount          = products_For_Sale.Total * plcdorder.Pieces;
                        if (plcdorder.Ispaid == true)
                        {
                            billing.Payment_Statement = "*** Paid by Paypal ***";
                        }
                        else
                        {
                            billing.Payment_Statement = "*** Pay on delivery ***";
                        }
                        //===============bill details entry=========================//

                        billing_Detail.Product_Token = plcdorder.Item_token;
                        billing_Detail.Pieces        = products_For_Sale.Pieces * plcdorder.Pieces;

                        billing_Detail.Tax       = (products_For_Sale.Amout_after_tax - products_For_Sale.Selling_Price) * plcdorder.Pieces;
                        billing_Detail.Discount  = decimal.Parse("0.00");
                        billing_Detail.Sub_Total = products_For_Sale.Total * plcdorder.Pieces;


                        //===============stockout entry=========================//

                        stockout.Product_Token = plcdorder.Item_token;
                        stockout.Pieces        = products_For_Sale.Pieces * plcdorder.Pieces;

                        stockout.CGST      = (products_For_Sale.Selling_Price * plcdorder.Pieces) + ((products_For_Sale.CGST * plcdorder.Pieces) / 100);
                        stockout.SGST      = (products_For_Sale.Selling_Price * plcdorder.Pieces) + ((products_For_Sale.SGST * plcdorder.Pieces) / 100);
                        stockout.Sub_Total = products_For_Sale.Total * plcdorder.Pieces;

                        //===========================================================//
                        billing.Billing_Details.Add(billing_Detail);
                        billing.Stockouts.Add(stockout);

                        using (var client = new HttpClient())
                        {
                            client.BaseAddress = new Uri("http://localhost:8087/api/Billing/PostShippingBill");

                            //HTTP POST
                            var postTask = client.PostAsJsonAsync("http://localhost:8087/api/Billing/PostShippingBill", billing);
                            postTask.Wait();

                            var result = postTask.Result;
                            if (result.IsSuccessStatusCode)
                            {
                                var nmbr = result.Content.ReadAsStringAsync()
                                           .Result
                                           .Replace("\\", "")
                                           .Trim(new char[1] {
                                    '"'
                                });
                                ViewBag.billno  = nmbr;
                                ViewBag.success = "Successfully approved";
                            }
                            else
                            {
                                ViewBag.error = "Something went wrong. Please try again.";
                            }
                        }
                    }
                    else
                    {
                        ViewBag.error = "Already approved";
                    }
                }
                placed_Order = db.Placed_Orders.Where(z => z.Orderplaced == false).Distinct().ToList();
                foreach (var plcdordrpending in placed_Order)
                {
                    pendingShipping.token = plcdordrpending.Token_number;
                    if (plcdordrpending.IsUser == true)
                    {
                        pendingShipping.Customer_name = db.Users.Where(z => z.Token_number == plcdordrpending.Customer_token).Select(z => z.Name).Distinct().FirstOrDefault();
                    }
                    else
                    {
                        pendingShipping.Customer_name = db.Customers.Where(z => z.Token_number == plcdordrpending.Customer_token).Select(z => z.Customer_Name).Distinct().FirstOrDefault();
                    }
                    pendingShipping.tyreName     = db.Products_For_Sales.Where(z => z.Token_Number == plcdordrpending.Item_token).Select(z => z.Product_name).Distinct().FirstOrDefault();
                    pendingShipping.Total_Piece  = plcdordrpending.Pieces;
                    pendingShipping.Total_Price  = (db.Products_For_Sales.Where(z => z.Token_Number == plcdordrpending.Item_token).Select(z => z.Total).Distinct().FirstOrDefault()) * plcdordrpending.Pieces;
                    pendingShipping.Applied_Date = plcdordrpending.Order_Date;
                    pendingShipping.Isuser       = plcdordrpending.IsUser;
                    if (plcdordrpending.Ispaid == true)
                    {
                        pendingShipping.paymentstatement = "Paid by Paypal";
                    }
                    else
                    {
                        pendingShipping.paymentstatement = "Pay on delivery";
                    }
                    pendingShippingList.Add(pendingShipping);
                    pendingShipping = new PendingShipping();
                }
            }
            if (ViewBag.error != null)
            {
                return(RedirectToAction("PendingShipping", new { sccess = ViewBag.error }));
            }
            else if (ViewBag.success != null)
            {
                return(RedirectToAction("PendingShipping", new { sccess = ViewBag.success, bllno = ViewBag.billno, id = "" }));
            }
            else
            {
                ViewBag.success = sccess;
                ViewBag.billno  = bllno;
                ViewBag.error   = sccess;
                return(View(pendingShippingList.ToPagedList(page ?? 1, 5)));
            }
        }
Example #23
0
        //添加出库库存
        public int Add(Stockout m)
        {
            string sql = string.Format("insert into Stockout values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", m.OrderNo, m.StockOutType, m.CustomerId, m.StockOutStatus, m.Remark, m.CreateBy, m.CreateDate, m.ModifiedBy, m.ModifiedDate);

            return(DBHelper.ExecuteNonQuery(sql));
        }