Ejemplo n.º 1
0
        public JsonResult Save(List<string> id, List<string> price, List<string> qty, string pay)
        {
            bool result = false;
            try
            {

                if (id.Count > 0)
                {
                    string orderNo = DateTime.Now.AddMonths(-1).ToString("yyyyMMddHHmmss");
                    DateTime now = DateTime.Now;

                    int total = 0;
                    for (int i = 0; i < id.Count; i++)
                    {
                        total += WebUtill.ConvertInt(price[i]) * WebUtill.ConvertInt(qty[i]);
                    }

                    ProductSellMasterModel master = new ProductSellMasterModel();
                    master.Company = new Dac_Company().CompanyInfoDetail(ObjectId.Parse(ConfigurationManager.AppSettings["COM"]));
                    master.Indate = now;
                    master.OrderNo = orderNo;
                    master.PayType = pay;
                    master.TotalPrice = total;
                    new Dac_Product().ProductSellMasterSave(master);

                    for (int i = 0; i < id.Count; i++)
                    {
                        for(int j=0; j < WebUtill.ConvertInt(qty[i]); j++)
                        {
                            ProductSellModel data = new ProductSellModel();
                            data.OrderNo = orderNo;
                            data.Product = new Dac_Product().ProductView(ObjectId.Parse(id[i]));
                            data.Price = WebUtill.ConvertInt(price[i]);
                            data.DiscountYn = "O";
                            data.PayType = pay;
                            data.Indate = now;
                            data.TotalPrice = total;
                            new Dac_Product().ProductSellSave(data);
                            result = true;
                        }
                    }
                }
                else
                {
                    result = false;
                }
            }
            catch(Exception ex)
            {
                result = false;
            }
            return Json(result);
        }
Ejemplo n.º 2
0
 public void ProductSellSave(ProductSellModel model)
 {
     new MongoDacHelper("productSell").Save<ProductSellModel>(model);
 }