Пример #1
0
        public int AddPurchase(PurchaseEntity newPurchase)
        {
            int status = -1;

            try
            {
                status = Execute(
                    $"INSERT INTO {base.GetTableName()} ([Id],[UserId],[Total],[TotalCount],[CreationDate],[IsConfirmed],[IsProcessed]) " +
                    "VALUES (@Id,@UserId, @Total, @TotalCount, @CreationDate,@IsConfirmed, @IsProcessed)", new
                {
                    newPurchase.Id,
                    newPurchase.UserId,
                    newPurchase.Total,
                    newPurchase.TotalCount,
                    newPurchase.CreationDate,
                    newPurchase.IsConfirmed,
                    newPurchase.IsProcessed
                });
            }
            catch (Exception)
            {
                return(-1);
            }

            return(status);
        }
        public bool InsertInfo(PurchaseEntity obj)
        {
            con = Connectionsql.Connection();
            bool term = SelectMysql.result("insert into  tb_purchase(purchaseId,commodityName,purchaseNumber,costPrice,total,purchaseDate" +
                                           ",handler,purchaseStatus) values(" + "'" + obj.PurchaseId + "'" + "," + "'" + obj.Productname + "'" + ","
                                           + "'" + obj.Purchasenumber + "'" + "," + "'" + obj.Costprice + "'" + "," + "'" + obj.Total + "'" + "," + "'" + obj.Purchasedate +
                                           "'" + "," + "'" + obj.Experience + "'" + "," + "'" + obj.Purchasestate + "')");

            try
            {
                if (term == true)
                {
                    return(term);
                }
            }
            catch (MySqlException e)
            {
                MessageBox.Show(e.Message, "提示", MessageBoxButtons.OK);
            }
            finally
            {
                con.Close();
            }

            return(term);
        }
Пример #3
0
        void Add(object sender, EventArgs e)
        {
            string name = shopName.Text;

            if (inUse.SelectedIndex == 0)
            {
                if (String.IsNullOrEmpty(name))
                {
                    return;
                }
                if (inUse.Items.Contains(name))
                {
                    DisplayAlert("Ошибка", "Данное имя уже существует", "Ок");
                    return;
                }
            }
            else
            {
                name = inUse.Items[inUse.SelectedIndex];
            }
            App.shops[fn] = name;
            PurchaseEntity pe = new PurchaseEntity
            {
                shop  = name,
                price = price
            };

            App.shopCategories[name] = (string)categories.SelectedItem;
            MainPage.list.Add(pe);
            Navigation.PopModalAsync();
        }
        public bool UpdateInfo(PurchaseEntity obj, string jobnumber)
        {
            con = Connectionsql.Connection();
            bool term = SelectMysql.result("update tb_purchase set purchaseId='" + obj.PurchaseId + "'," +
                                           "commodityName='" + obj.Productname + "',purchaseNumber='" + obj.Purchasenumber + "',costPrice='" + obj.Costprice + "',total=" +
                                           "'" + obj.Total + "',purchaseDate='" + obj.Purchasedate + "'" +
                                           ",handler='" + obj.Experience + "',purchaseStatus='" + obj.Purchasestate + "' where purchaseId='" + jobnumber + "'");

            try
            {
                if (term == true)
                {
                    return(term);
                }
            }
            catch (MySqlException e)
            {
                MessageBox.Show(e.Message, "提示", MessageBoxButtons.OK);
            }
            finally
            {
                con.Close();
            }

            return(term);
        }
        public async Task <UserPurchaseModel> CreateNewPurchase(UserObject parent, string description, DateTime purchaseDate, decimal price)
        {
            using (var dataContext = new AppDbContext())
            {
                var p = new PurchaseEntity
                {
                    Description  = description,
                    PurchaseDate = purchaseDate,
                    Price        = price,
                    UserId       = parent.Id
                };

                var publishers = dataContext.Purchases.Add(p);

                var retval = dataContext.SaveChanges();

                return(new UserPurchaseModel
                {
                    Id = p.Id,
                    Description = p.Description,
                    PurchaseDate = p.PurchaseDate.ToString("MM/dd/yyyy"),
                    Price = String.Format("{0:C2}", p.Price)
                });
            }
        }
Пример #6
0
 /// <summary>
 /// Converte bal entity to entity on dal
 /// </summary>
 /// <param name="entity">entity to be converted</param>
 /// <returns>dal entity</returns>
 public static DALPurchase ToDallPurchase(this PurchaseEntity purchase)
 {
     return(new DALPurchase()
     {
         BuyerName = purchase.BuyerName,
     });
 }
Пример #7
0
        /// <summary>
        /// 新增采购订单
        /// </summary>
        /// <returns></returns>
        public ActionResult Create()
        {
            string         CompanyID         = WebUtil.GetFormValue <string>("CompanyID", string.Empty);
            PurchaseEntity entity            = WebUtil.GetFormObject <PurchaseEntity>("Entity");
            List <PurchaseDetailEntity> list = WebUtil.GetFormObject <List <PurchaseDetailEntity> >("List");

            entity.SnNum        = ConvertHelper.NewGuid();
            entity.AuditeStatus = (int)EAudite.Wait;
            entity.Status       = (int)EPurchaseStatus.CreateOrder;
            entity.IsDelete     = (int)EIsDelete.NotDelete;
            entity.CreateTime   = DateTime.Now;
            entity.CompanyID    = entity.CompanyID.IsEmpty() ? CompanyID : entity.CompanyID;

            Bill <PurchaseEntity, PurchaseDetailEntity> bill = new PurchaseOrder(CompanyID);
            string     returnValue = bill.Create(entity, list);
            DataResult result      = new DataResult();

            if (EnumHelper.GetEnumDesc <EReturnStatus>(EReturnStatus.Success) == returnValue)
            {
                result.Code    = (int)EResponseCode.Success;
                result.Message = "采购订单创建成功";
            }
            else
            {
                result.Code    = (int)EResponseCode.Exception;
                result.Message = "采购订单创建失败";
            }
            return(Content(JsonHelper.SerializeObject(result)));
        }
Пример #8
0
 private static PurchaseEntity ProjectTo(Purchase source, PurchaseEntity destination)
 {
     destination.Amount       = source.Value.Amount;
     destination.CurrencyCode = source.Value.Currency.Code;
     destination.SpentAt      = source.SpentAt;
     return(destination);
 }
Пример #9
0
 public bool bay(ProductEntity p, int count, Check c)
 {
     if (count > p.count)
     {
         return(false);
     }
     else
     {
         BDManager.manager.beginTranc();
         p.count -= count;
         updateProduct(p);
         PurchaseEntity o = new PurchaseEntity
         {
             bayCount  = count,
             check     = c.entity,
             checkId   = c.entity.checkId,
             product   = p,
             productId = p.productId
         };
         BDManager.manager.addPurchase(o);
         BDManager.manager.Commit();
         BDManager.manager.getChildren(c.entity);
         return(true);
     }
 }
Пример #10
0
        static void Main(string[] args)
        {
            var compositor   = new ServiceCompositor();
            var inputManager = compositor.GetService <InputManager>();

            var calculator = compositor.GetService <RetailCalculatorService>();

            var purchase = new PurchaseEntity();

            purchase.Price = inputManager.GetPrice();
            purchase.Count = (int)inputManager.GetItemCount();

            var state = inputManager.GetState(calculator.GetTaxStates());

            Console.WriteLine($"Taxes for state {state} are {calculator.GetTaxCharge(state).ToTaxPercentage()}");
            var partial = calculator.CalculateTotal(purchase, state);

            Console.WriteLine($"Total: {partial}");

            var discount = calculator.FigureDiscount(partial);

            Console.WriteLine($"Applying a discount of {discount.ToTaxPercentage()}");
            Console.WriteLine($"Total: {calculator.CalculateTotal(purchase, state, true)}");
            Console.ReadLine();
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Date")] PurchaseEntity purchaseEntity)
        {
            if (id != purchaseEntity.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(purchaseEntity);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PurchaseEntityExists(purchaseEntity.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(purchaseEntity));
        }
        public async Task <IActionResult> PutPurchaseEntity([FromRoute] int id, [FromBody] PurchaseEntity purchaseEntity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != purchaseEntity.Id)
            {
                return(BadRequest());
            }

            _context.Entry(purchaseEntity).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PurchaseEntityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #13
0
        private void button1_Click(object sender, EventArgs e)
        {
            string purchaseId     = textBox5_JHID.Text;
            string commodityName  = textBox6_SPMC.Text;
            string purchaseNumber = textBox8_JHSL.Text;
            int    number         = int.Parse(purchaseNumber);
            string costPrice      = textBox7_CBJ.Text;
            int    price          = int.Parse(costPrice);
            string total          = textBox1_ZE.Text;
            int    pay            = int.Parse(total);
            string purchaseDate   = dateTimePicker1.Text;
            string handler        = textBox3_JSR.Text;
            string purchaseStatus = comboBox1_JHZT.Text;

            PurchaseEntity            entity           = new PurchaseEntity(purchaseId, commodityName, number, price, pay, purchaseDate, handler, purchaseStatus);
            IPurchaseManageController manageController = new PurchaseManageControllerImpl();

            bool term = manageController.InsertPurchaseInfo(entity);

            if (term == true)
            {
                PurchaseManage form = new PurchaseManage();
                MessageBox.Show("添加进货信息成功");
                this.DialogResult = DialogResult.OK;
                this.Hide();
            }
            else
            {
                MessageBox.Show("添加进货信息失败!");
            }
        }
Пример #14
0
 private Purchase Map(PurchaseEntity source)
 {
     return(new Purchase(
                source.PurchaseId,
                new Money(source.Amount, _currencyProvider.Provide(source.CurrencyCode)),
                source.SpentAt
                ));
 }
Пример #15
0
        /// <summary>
        /// 查询采购订单分页列表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetOrderList()
        {
            string CompanyID     = WebUtil.GetFormValue <string>("CompanyID");
            int    PageIndex     = WebUtil.GetFormValue <int>("PageIndex", 1);
            int    PageSize      = WebUtil.GetFormValue <int>("PageSize", 10);
            string OrderNum      = WebUtil.GetFormValue <string>("OrderNum");
            int    OrderType     = WebUtil.GetFormValue <int>("OrderType", 0);
            string SupNum        = WebUtil.GetFormValue <string>("SupNum");
            string SupName       = WebUtil.GetFormValue <string>("SupName");
            string Contact       = WebUtil.GetFormValue <string>("Contact");
            string Phone         = WebUtil.GetFormValue <string>("Phone");
            string ContractOrder = WebUtil.GetFormValue <string>("ContractOrder");
            int    AuditeStatus  = WebUtil.GetFormValue <int>("AuditeStatus", 0);
            int    Status        = WebUtil.GetFormValue <int>("Status", 0);

            string BeginTime      = WebUtil.GetFormValue <string>("BeginTime");
            string EndTime        = WebUtil.GetFormValue <string>("EndTime");
            string BeginOrderTime = WebUtil.GetFormValue <string>("BeginOrderTime");
            string EndOrderTime   = WebUtil.GetFormValue <string>("EndOrderTime");
            string BeginRevDate   = WebUtil.GetFormValue <string>("BeginRevDate");
            string EndRevDate     = WebUtil.GetFormValue <string>("EndRevDate");

            PurchaseEntity entity = new PurchaseEntity();

            entity.CompanyID      = CompanyID;
            entity.OrderNum       = OrderNum;
            entity.OrderType      = OrderType;
            entity.SupNum         = SupNum;
            entity.SupName        = SupName;
            entity.Contact        = Contact;
            entity.Phone          = Phone;
            entity.ContractOrder  = ContractOrder;
            entity.AuditeStatus   = AuditeStatus;
            entity.Status         = Status;
            entity.BeginTime      = BeginTime;
            entity.EndTime        = EndTime;
            entity.BeginOrderTime = BeginOrderTime;
            entity.EndOrderTime   = EndOrderTime;
            entity.BeginRevDate   = BeginRevDate;
            entity.EndRevDate     = EndRevDate;

            Bill <PurchaseEntity, PurchaseDetailEntity> bill = new PurchaseOrder(CompanyID);
            PageInfo pageInfo = new PageInfo()
            {
                PageIndex = PageIndex, PageSize = PageSize
            };

            List <PurchaseEntity>           listResult = bill.GetList(entity, ref pageInfo);
            DataListResult <PurchaseEntity> dataResult = new DataListResult <PurchaseEntity>()
            {
                Code     = (int)EResponseCode.Success,
                Message  = "响应成功",
                Result   = listResult,
                PageInfo = pageInfo
            };

            return(Content(JsonHelper.SerializeObject(dataResult)));
        }
Пример #16
0
 /// <summary>
 /// 验证订单
 /// </summary>
 /// <param name="info"></param>
 /// <param name="purchase"></param>
 /// <returns></returns>
 protected virtual bool ValidatePurchase(PurchasePayEntity info, PurchaseEntity purchase)
 {
     if (purchase == null)
     {
         info.AddErrorByName(typeof(PurchaseEntity).FullName, "NoExist");
         return(false);
     }
     return(true);
 }
        // GET: Purchases/Create
        public async Task <IActionResult> Create()
        {
            PurchaseEntity model = new PurchaseEntity();

            model.Date = DateTime.Now;
            model.PurchaseItemDetails    = new List <PurchaseItemDetailEntity>();
            model.PurchaseServiceDetails = new List <PurchaseServiceDetailEntity>();
            return(View(model));
        }
        /// <summary>
        /// add purchase to the shop
        /// </summary>
        /// <param name="purch">purchase to be added</param>
        public void RegisterPurchase(PurchaseEntity purch)
        {
            if (ReferenceEquals(purch, null))
            {
                throw new ArgumentNullException($"{nameof(purch)} must not be null");
            }

            purchaseService.Create(purch.ToDallPurchase());
            purchaseService.Commit();
        }
Пример #19
0
 public static DalPurchase ToDalPurchase(this PurchaseEntity purchaseEntity)
 {
     return(new DalPurchase
     {
         Id = purchaseEntity.Id,
         Date = purchaseEntity.Date,
         LotId = purchaseEntity.LotId,
         UserId = purchaseEntity.UserId
     });
 }
        public float CalculateTotal(PurchaseEntity purchase, string state, bool applyDiscount = false)
        {
            var partial = Calculator.CalculcateTotal(purchase);
            var total   = TaxCalculator.CalculateTaxes(partial, state);

            if (applyDiscount)
            {
                total = DiscountCalculator.ApplyDescount(total);
            }
            return(total);
        }
Пример #21
0
        public static PurchaseEntity ToPurchaseEntity(this PurchaseViewModel model)
        {
            PurchaseEntity entity = new PurchaseEntity();

            entity.IsExecuted   = model.IsExecuted;
            entity.ProductList  = model.ProductList;
            entity.Provider     = model.Provider;
            entity.PurchaseDate = model.PurchaseDate;
            entity.TotalSum     = model.TotalSum;
            return(entity);
        }
        public async Task <IActionResult> PostPurchaseEntity([FromBody] PurchaseEntity purchaseEntity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Purchases.Add(purchaseEntity);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPurchaseEntity", new { id = purchaseEntity.Id }, purchaseEntity));
        }
Пример #23
0
 public UpdatePurchase(PurchaseEntity purchaseEntity)
 {
     InitializeComponent();
     textBox5_JHID.Text   = purchaseEntity.PurchaseId;
     textBox6_SPMC.Text   = purchaseEntity.Productname;
     textBox8_JHSL.Text   = purchaseEntity.Purchasenumber.ToString();
     textBox7_CBJ.Text    = purchaseEntity.Costprice.ToString();
     textBox1_ZE.Text     = purchaseEntity.Total.ToString();
     dateTimePicker1.Text = purchaseEntity.Purchasedate;
     textBox3_JSR.Text    = purchaseEntity.Experience;
     comboBox1_JHZT.Text  = purchaseEntity.Purchasestate;
 }
Пример #24
0
        public void CalculatePrice()
        {
            var expected = 4f;
            var sut      = new PriceCalculationService();
            var purchase = new PurchaseEntity
            {
                Count = 2,
                Price = 2
            };

            Assert.Equal(expected, sut.CalculcateTotal(purchase));
        }
Пример #25
0
        public static PurchaseViewModel ToPurchaseViewModel(this PurchaseEntity entity)
        {
            PurchaseViewModel model = new PurchaseViewModel();

            model.Id           = entity.Id;
            model.IsExecuted   = entity.IsExecuted;
            model.ProductList  = entity.ProductList;
            model.Provider     = entity.Provider;
            model.PurchaseDate = entity.PurchaseDate;
            model.TotalSum     = entity.TotalSum;
            return(model);
        }
Пример #26
0
        public async Task <PurchaseEntity> SavePurchase(PurchaseEntity purchase)
        {
            var orderFromDb = await Query.Where(e => e.Id == purchase.Id).FirstOrDefaultAsync();

            if (orderFromDb == null)
            {
                return((await SaveEntity(purchase.ToPurchase(null))).ToPurchaseEntity());
            }
            else
            {
                return((await SaveEntity(purchase.ToPurchase(orderFromDb))).ToPurchaseEntity());
            }
        }
        public async Task <IActionResult> Create(PurchaseEntity purchaseEntity)
        {
            if (ModelState.IsValid)
            {
                purchaseEntity.User = await _userHelper.GetUserAsync(this.User.Identity.Name);

                _context.Add(purchaseEntity);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(purchaseEntity));
        }
Пример #28
0
 /// <summary>
 /// 验证订单
 /// </summary>
 /// <param name="info"></param>
 /// <param name="purchase"></param>
 /// <returns></returns>
 protected virtual bool ValidatePurchase(PurchaseItemEntity info, out PurchaseEntity purchase)
 {
     purchase = info.Purchase == null ? null
                   : info.Purchase.SaveType == SaveType.Add
                         ? info.Purchase
                         : Repository.Get <PurchaseEntity>(info.Purchase.Id);
     if (purchase == null)
     {
         info.AddErrorByName(typeof(PurchaseEntity).FullName, "NoExist");
         return(false);
     }
     return(true);
 }
Пример #29
0
        private void button1_Click(object sender, EventArgs e)
        {
            PurchaseEntity            entity           = PurchaseUpdate();
            IPurchaseManageController manageController = new PurchaseManageControllerImpl();
            bool term = manageController.UpdatePurchaseInfo(entity, purchaseId);

            if (term == true)
            {
                MessageBox.Show("修改进货信息成功!");
                this.DialogResult = DialogResult.OK;
                this.Hide();
            }
        }
Пример #30
0
 protected override void Page_Load(object sender, EventArgs e)
 {
     base.Page_Load(sender, e);
     if (PurchaseId > 0)
     {
         var query = new QueryInfo();
         query.Query <PurchaseEntity>().Where(it => it.Id == PurchaseId).Select(it => new object[] { it, it.Account, it.Order });
         Purchase = Ioc.Resolve <IApplicationService, PurchaseEntity>().GetEntities <PurchaseEntity>(query).FirstOrDefault();
     }
     if (!IsPostBack)
     {
         BindStockItemEntities();
     }
 }