예제 #1
0
        public void AddBillItem(String id, int value, bool isInCome, DateTime date, String detail)
        {
            var newItem = new BillItem(id, value, isInCome, date, detail);

            this.items.Add(newItem);
            UpdateBalance(isInCome, value);
        }
예제 #2
0
파일: DomainTest.cs 프로젝트: zszqwe/Wilson
        public void Adding_BillItem_To_BIll()
        {
            var date      = new DateTime(2017, 6, 19);
            var billItems = ListOfBillItems.Create();
            var projectId = Guid.NewGuid().ToString();

            var storeHouseItemAId      = Guid.NewGuid().ToString();
            var storehuseItemAQuantity = 15;
            var billItemA = BillItem.Create(5, 2.5M, storeHouseItemAId, storehuseItemAQuantity);

            var storeHouseItemBId      = Guid.NewGuid().ToString();
            var storehuseItemBQuantity = 15;
            var billItemB = BillItem.Create(4, 2.5M, storeHouseItemBId, storehuseItemBQuantity);

            var bill = Bill.Create(date, billItems, projectId);

            Assert.True(bill.GetBillItems().Count() == 0);

            bill.AddBillItem(billItemA);
            Assert.True(bill.GetBillItems().Count() == 1);

            bill.AddBillItem(billItemB);
            Assert.True(bill.GetBillItems().Count() == 2);

            bill.AddBillItem(billItemA);
            Assert.True(bill.GetBillItems().Count() == 2);
        }
예제 #3
0
        private void button_Submit_Click(object sender, EventArgs e)
        {
            BillItem billItem = new BillItem();
            string   remark   = "";

            foreach (string line in textBox_Remark.Lines)
            {
                remark += line;
                remark += Environment.NewLine;
            }

            if (checkPricePassed(billItem.ItemPrice))
            {
                billItem.ItemPrice = double.Parse(textBox_ItemPrice.Text);
                billItem.ItemName  = textBox_ItemName.Text;
                billItem.Date      = InsertDatePicker.Value;
                billItem.Remark    = remark;
                BillItemService billItemService = new BillItemService();
                bool            check           = billItemService.saveNewBill(billItem);
                if (check)
                {
                    MessageBox.Show("录入成功");
                    reset();
                }
            }
            else
            {
                MessageBox.Show("请检查输入");
            }
        }
예제 #4
0
        public List <BillItem> ReadBillItems(int agentId, int countryId, int visaOneId, int visaTwoId)
        {
            DbCommand dbCommand = myDataBase.GetStoredProcCommand(DBConstant.READ_NEW_BILL_CHARGES);

            dbCommand.CommandType = CommandType.StoredProcedure;
            List <BillItem> lstBill = new List <BillItem>();

            myDataBase.AddInParameter(dbCommand, "@VisaTypeOneId", DbType.Int32, visaOneId);
            myDataBase.AddInParameter(dbCommand, "@VisaTypeTwoId", DbType.Int32, visaTwoId);
            myDataBase.AddInParameter(dbCommand, "@CountryId", DbType.Int32, countryId);
            myDataBase.AddInParameter(dbCommand, "@agentId", DbType.Int32, agentId);


            using (IDataReader reader = myDataBase.ExecuteReader(dbCommand))
            {
                while (reader.Read())
                {
                    BillItem billItem = new BillItem();


                    billItem.BillItemDescription = GetStringFromDataReader(reader, "DESCRIPTION");
                    billItem.ItemCharge          = GetDecimalFromDataReader(reader, "CHARGE");


                    lstBill.Add(billItem);
                }
                return(lstBill);
            }
        }
예제 #5
0
        public Bill AddProductToBill(long billId, string productBarCode, int quantity)
        {
            Bill bill = unitOfWork.BillRepository.GetById(billId);

            VerifyIfProductExists(productBarCode);
            Product product = unitOfWork.ProductRepository.FindBy(p => p.BarCode == productBarCode).ToList().FirstOrDefault();


            BillItem billItem = new BillItem();

            billItem.Product  = product;
            billItem.Quantity = quantity;
            if (bill.BillItems != null)
            {
                BillItem existingBillItem = bill.BillItems.Where(b => b.Product.BarCode == productBarCode).FirstOrDefault();
                if (existingBillItem == null)
                {
                    bill.BillItems.Add(billItem);
                }
                else
                {
                    existingBillItem.Quantity++;
                }
            }
            else
            {
                bill.BillItems = new List <BillItem>();
                bill.BillItems.Add(billItem);
            }
            unitOfWork.BillItemRepository.Insert(billItem);
            unitOfWork.BillRepository.Edit(bill);
            unitOfWork.Save();
            return(bill);
        }
예제 #6
0
        public double CalculateValueForItem(BillItem billItem)
        {
            ProductValueCalculator productValueCalculator;
            double productValue = 0;

            switch (billItem?.Product?.Category)
            {
            case Category.A:
                productValueCalculator = new ProductValueCalculator(new ProductCatAStrategy());
                break;

            case Category.B:
                productValueCalculator = new ProductValueCalculator(new ProductCatBStrategy());
                break;

            case Category.C:
                productValueCalculator = new ProductValueCalculator(new ProductCatCStrategy());
                break;

            default:
                productValueCalculator = new ProductValueCalculator(new ProductCatCStrategy());
                break;
            }
            productValue = productValueCalculator.CalculateValue(billItem);
            return(productValue);
        }
예제 #7
0
        /// <summary>
        /// 获取所有款项统计信息
        /// isCurrent: true:当期欠费科目集合 false:逾期欠费集合
        /// </summary>
        /// <returns></returns>
        public virtual List <BillItem> GetStatisticsItems(bool?isCurrent = false)
        {
            var bills = BillDAL.GetNormalBills(Business.Bills);

            List <BillItem> billItems = new List <BillItem>();

            bills.ForEach(o =>
            {
                if (o.BillItems != null)
                {
                    billItems.AddRange(o.BillItems);
                }
            });

            List <BillItem> tempItems = new List <BillItem>();
            var             pdtItems  = GetProductItems();

            foreach (var pdtItem in pdtItems)
            {
                BillItem item        = new BillItem();
                var      filterItems = billItems.Where(p => p.Subject == pdtItem.Key).ToList();
                if (isCurrent != null)
                {
                    filterItems = filterItems.Where(p => p.IsCurrent == isCurrent.Value).ToList();
                }
                item.Amount      = filterItems.Sum(p => p.Amount);
                item.DueAmt      = filterItems.Sum(p => p.DueAmt);
                item.ReceivedAmt = filterItems.Sum(p => p.ReceivedAmt);
                item.StrSubject  = pdtItem.Value.Replace("月", string.Empty);
                item.Subject     = pdtItem.Key;
                tempItems.Add(item);
            }

            return(tempItems);
        }
예제 #8
0
        public List <BillItem> ReadBillIDBill(int billid, int id)
        {
            List <BillItem> lst       = new List <BillItem>();
            DbCommand       dbCommand = myDataBase.GetStoredProcCommand(DBConstant.READ_BILLDETAILSBY_ID);

            if (billid != 0)
            {
                myDataBase.AddInParameter(dbCommand, "@billId", DbType.Int32, billid);
            }
            else
            {
                myDataBase.AddInParameter(dbCommand, "@billId", DbType.Int32, DBNull.Value);
            }
            if (id != 0)
            {
                myDataBase.AddInParameter(dbCommand, "@id", DbType.Int32, id);
            }
            else
            {
                myDataBase.AddInParameter(dbCommand, "@id", DbType.Int32, DBNull.Value);
            }
            using (IDataReader reader = myDataBase.ExecuteReader(dbCommand))
            {
                while (reader.Read())
                {
                    BillItem billItemDOM = new BillItem();
                    billItemDOM.BillItemId = GetIntegerFromDataReader(reader, "id");
                    lst.Add(billItemDOM);
                }
            }
            return(lst);
        }
예제 #9
0
        public List <BillItem> ReadInvoiceDetails(Int32 visaTypeOneId, Int32 visaTypeTwoId, Int32 AgentId, Int32 CountryId)
        {
            List <BillItem> lstBillItem = new List <BillItem>();
            DbCommand       dbCommand   = myDataBase.GetStoredProcCommand(DBConstant.READ_NEWBILLCHARGE);

            myDataBase.AddInParameter(dbCommand, "@VisaTypeOneId", DbType.Int32, visaTypeOneId);
            myDataBase.AddInParameter(dbCommand, "@VisaTypeTwoId", DbType.Int32, visaTypeTwoId);
            myDataBase.AddInParameter(dbCommand, "@agentId", DbType.Int32, AgentId);
            myDataBase.AddInParameter(dbCommand, "@CountryId ", DbType.Int32, CountryId);

            using (IDataReader reader = myDataBase.ExecuteReader(dbCommand))
            {
                while (reader.Read())
                {
                    BillItem billItemDOM = new BillItem();
                    billItemDOM.BillItemDescription = GetStringFromDataReader(reader, "DESCRIPTION");
                    billItemDOM.ItemCharge          = GetDecimalFromDataReader(reader, "CHARGE");
                    if (CountryId == 0)
                    {
                        billItemDOM.CountryId = 0;
                    }
                    else
                    {
                        billItemDOM.CountryId = GetIntegerFromDataReader(reader, "CountryId");
                    }
                    lstBillItem.Add(billItemDOM);
                }
            }
            return(lstBillItem);
        }
예제 #10
0
 /// <summary>
 /// 针对刚创建的帐单科目添加调整款项
 /// </summary>
 /// <param name="tempReceived"></param>
 /// <param name="tempBillItems"></param>
 /// <param name="receivedList"></param>
 /// <param name="filter"></param>
 private static void AddBillItemAndReceivedItem(List <Received> tempReceived
                                                , List <string> tempBillItems
                                                , List <Received> receivedList
                                                , List <BillItem> billItems
                                                , PayAccountFilter filter)
 {
     if (tempBillItems.Count > 0)
     {
         foreach (var strbillItem in tempBillItems)
         {
             var arr      = strbillItem.Split('_');
             var billItem = new BillItem
             {
                 BillID      = arr[0].ToLong(),
                 CreateTime  = DateTime.Now,
                 Subject     = arr[1].ToByte(),
                 SubjectType = (byte)EnumSubjectKind.Supplement,
                 Amount      = arr[2].ToDecimal(),
                 DueAmt      = arr[2].ToDecimal(),
                 OperatorID  = filter.UserId,
             };
             billItems.Add(billItem);
         }
         receivedList.AddRange(tempReceived);
     }
 }
        public IHttpActionResult PutBillItem(int id, BillItem billItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            Repository.Update(billItem);
            try
            {
                Repository.Save();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BillItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        /// <summary>
        /// 转换成实收信息
        /// </summary>
        /// <param name="bill"></param>
        /// <param name="billItem"></param>
        /// <param name="lstReceiveDetailViewDatas"></param>
        /// <returns></returns>
        private List <Received> ConvertToReceived(Bill bill
                                                  , BillItem billItem
                                                  , List <Received> lstReceiveDetailViewDatas)
        {
            List <Received> lstReceives = new List <Received>();

            if (lstReceiveDetailViewDatas == null || lstReceiveDetailViewDatas.Count == 0)
            {
                return(null);
            }

            List <Received> lstReceive = lstReceiveDetailViewDatas.Where(x => x.BillItemID == billItem.BillItemID).ToList();

            if (lstReceive == null || lstReceive.Count == 0)
            {
                return(null);
            }

            foreach (var detail in lstReceive)
            {
                detail.Bill     = bill;
                detail.BillItem = billItem;
            }

            return(lstReceive);
        }
        public async Task <IActionResult> BillItemEdit(int id, [FromBody] BillItem billItem)
        {
            if (id != billItem.Id)
            {
                Console.WriteLine("Không đúng định dạng");
                return(BadRequest());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(billItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BillItemExists(billItem.Id))
                    {
                        Console.WriteLine("Id không tồn tại");
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(Ok(billItem));
        }
        public async Task <BillDto> Handle(CreateBillRequest request, CancellationToken cancellationToken)
        {
            var billItems = request.BillFormModel.BillItems.Select(item =>
            {
                var billItem = new BillItem(item.BillItem.Description, item.BillItem.Amount, item.BillItem.Discount);

                if (item.PersonId > 0)
                {
                    billItem.AssignPerson(item.PersonId, item.BillItem.Amount);
                }
                return(billItem);
            }).ToList();
            var billToCreate = new Bill(request.BillFormModel.EstablishmentName, request.BillFormModel.BillDate, billItems, request.BillFormModel.Currency);

            billToCreate.Remarks = request.BillFormModel.Remarks;
            billToCreate.SetExternalId(_externalIdGenerator.Generate());


            billToCreate.SetBillItems(billItems);
            billToCreate.SetExtraCharges(request.BillFormModel.ExtraCharges.Select(item => new Core.OwnedEntities.ExtraCharge(item.Description, item.Rate)).ToList());

            request.BillFormModel.Participants.ForEach(participant =>
            {
                billToCreate.AddParticipant(participant.Person.Id);
            });

            _splitThatBillContext.Attach(_contextData.CurrentUser);
            billToCreate.UpdateBillTaker(_contextData.CurrentUser);

            _splitThatBillContext.Add(billToCreate);

            await _splitThatBillContext.SaveChangesAsync();

            return(_mapper.Map <BillDto>(billToCreate));
        }
예제 #15
0
        public async void SaveBillEntry()
        {
            await BillService.SaveAsync(Bill);

            Bill = new BillItem();
            await SaveEventCallBack.InvokeAsync(true);
        }
        public void LoadBillItemDetailViewModelsSortedByPositionViaPassedBill()
        {
            // Arrange
            Bill bill = ModelFactory.GetDefaultBill();

            bill.BillItems.Clear();

            BillItem billItem1 = new BillItem()
            {
                Position = 2
            };
            BillItem billItem2 = new BillItem()
            {
                Position = 1
            };

            bill.AddBillItem(billItem1);
            bill.AddBillItem(billItem2);

            // Act
            this._billItemEditViewModel.LoadBill(bill);

            // Assert
            this._billItemEditViewModel.BillItemDetailViewModels.Should().HaveCount(2);
            this._billItemEditViewModel.BillItemDetailViewModels[0].Position.Should().Be(1);
            this._billItemEditViewModel.BillItemDetailViewModels[1].Position.Should().Be(2);
        }
        public void MovesItemDown()
        {
            // Arrange
            Bill bill = new Bill();

            for (int i = 0; i < 5; i++)
            {
                BillItem billItem = ModelFactory.GetDefaultBillItem();
                billItem.Position = i + 1;
                billItem.Amount   = i + 1;
                bill.AddBillItem(billItem);
            }

            // Act
            this._billItemEditViewModel.LoadBill(bill);
            Messenger.Default.Send(new NotificationMessage <bool>(true, Resources.Message_EnableStateForBillItemEditVM));
            this._billItemEditViewModel.SelectedBillItemDetailViewModel = this._billItemEditViewModel.BillItemDetailViewModels[2];
            this._billItemEditViewModel.MoveItemDownCommand.RelayCommand.Execute(null);

            // Assert
            this._billItemEditViewModel.BillItemDetailViewModels[2].Position.Should().Be(3);
            this._billItemEditViewModel.BillItemDetailViewModels[2].Amount.Should().Be(4);
            this._billItemEditViewModel.BillItemDetailViewModels[3].Position.Should().Be(4);
            this._billItemEditViewModel.BillItemDetailViewModels[3].Amount.Should().Be(3);
        }
        public void UpdatesPositionsWhenBillItemWasDeleted()
        {
            // Arrange
            Bill bill = new Bill();

            for (int i = 0; i < 5; i++)
            {
                BillItem billItem = ModelFactory.GetDefaultBillItem();
                billItem.Position = i + 1;
                bill.AddBillItem(billItem);
            }

            // Act
            this._billItemEditViewModel.LoadBill(bill);
            this._billItemEditViewModel.SelectedBillItemDetailViewModel = this._billItemEditViewModel.BillItemDetailViewModels[2];
            Messenger.Default.Send(new NotificationMessage <bool>(true, Resources.Message_EnableStateForBillItemEditVM));
            this._billItemEditViewModel.DeleteItemCommand.RelayCommand.Execute(null);

            // Assert
            for (int i = 0; i < this._billItemEditViewModel.BillItemDetailViewModels.Count; i++)
            {
                int currentPosition = i + 1;
                this._billItemEditViewModel.BillItemDetailViewModels[i].Position.Should().Be(currentPosition);
            }
        }
        /// <summary>
        /// 为提前清贷订单进行自动填帐收款
        /// </summary>
        /// <param name="business"></param>
        /// <param name="payid"></param>
        /// <param name="filter"></param>
        /// <param name="lstUpdateItem"></param>
        /// <param name="lstReceived"></param>
        protected void AutoReceivedByCLoan(Business business, int payid, PayAccountFilter filter
                                           , List <UpdateItem> lstUpdateItem, List <Received> lstReceived)
        {
            var bills = BillDAL.GetArrearsBills(business.Bills);

            CloanApply apply    = null;
            var        lstApply = Singleton <CloanApplyDetailDAL <CloanApply> > .Instance.SearchData(filter);

            if (lstApply == null || lstApply.Count == 0)
            {
                return;
            }

            apply = lstApply[0];
            IEnumerable <CloanApplyItem> items = new List <CloanApplyItem>();

            if (apply != null)
            {
                filter.CloanApplyID   = apply.CloanApplyID;
                apply.CloanApplyItems = Singleton <CloanApplyItemDetailDAL <CloanApplyItem> > .Instance.SearchData(filter);

                items = apply.CloanApplyItems.Where(p => p.IsAnnul);
            }

            if (bills.Count > 0)
            {
                if (items.Count() > 0)//有减免项,先做减免
                {
                    //提前清贷服务费重置为不包括减免金额
                    Bill     advbill  = bills.FirstOrDefault(p => p.BillType == (byte)EnumBillKind.Advance);
                    BillItem billitem = advbill.BillItems.FirstOrDefault(p => p.Subject == (byte)EnumCostSubject.AdvServiceFee);

                    billitem.DueAmt = billitem.DueAmt + items.Sum(p => p.Amount);
                    lstUpdateItem.Add(new UpdateItem
                    {
                        Id     = billitem.BillItemID,
                        Amount = billitem.DueAmt,
                        Type   = 2
                    });
                    //billItemDAL.Update(billitem);
                    foreach (var item in items)
                    {
                        AnnulBillItemBySubAndAmount(bills, item.Subject, item.Amount, payid, DateTime.Now, lstReceived, lstUpdateItem);
                    }
                }

                foreach (var bill in bills)
                {
                    FtpAdvRecevied(bill.BillItems.Where(p => p.DueAmt - p.ReceivedAmt > 0).ToList(), payid, DateTime.Now
                                   , filter.UserId, filter.Explain, lstReceived, lstUpdateItem, EnumAdjustKind.Transfer);
                }
                //apply.CloanApplyStatus = (byte)EnumCloanApplyStatus.Success;
                //cLoanApplyDAL.Update(apply);
            }
            else
            {
                m_Logger.Error("提前清贷出错,未找到相应账单:" + business.BusinessID);;
            }
        }
예제 #20
0
        private async void GenerateSmsReport(int billId)
        {
            BillItem bill      = BillsItems.First(b => b.Id == billId);
            var      smsReport = new SmsSimpleReport(DialogService, bill);

            smsReport.Generate();
            await smsReport.CopyToBuffer();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            BillItem billItem = db.BillItems.Find(id);

            db.BillItems.Remove(billItem);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #22
0
 internal static void InsertBillItem(BillItem billItem)
 {
     using (IDbConnection cnn = new SQLiteConnection(LoadWarehouseConnectionString()))
     {
         var query = GetGenericQueryString(billItem);
         cnn.Execute(query, billItem);
     }
 }
예제 #23
0
 internal static void DeleteItem(BillItem item)
 {
     using (IDbConnection cnn = new SQLiteConnection(LoadWarehouseConnectionString()))
     {
         cnn.Execute($"delete from BillItem" +
                     $" where productIdent={item.productIdent}", new DynamicParameters());
     }
 }
예제 #24
0
        public void AddBillItem(int value, bool isInCome, DateTime date, String detail)
        {
            var newItem = new BillItem("", value, isInCome, date, detail);

            items.Add(newItem);
            //db.insert(newItem.getId(), title, detail, date, image);
            UpdateBalance(isInCome, value);
        }
예제 #25
0
 internal static void UpdateItem(BillItem existingItem)
 {
     using (IDbConnection cnn = new SQLiteConnection(LoadWarehouseConnectionString()))
     {
         cnn.Execute($"update BillItem " +
                     $"set quantity={existingItem.Quantity}, productCena={existingItem.productCena}, productPopust={existingItem.productPopust} " +
                     $"where productIdent={existingItem.productIdent}", new DynamicParameters());
     }
 }
        private void UpdateBill()
        {
            using (EditBill editBill = new EditBill())
            {
                editBill.txtDiscount.text   = txtDiscount.Text;
                editBill.txtTotal.text      = txtAmount.Text;
                editBill.txtFinal.text      = txtFinal.Text;
                editBill.txtPayMade.text    = txtPayMade.Text;
                editBill.txtBalance.text    = txtBalance.Text;
                editBill.txtSem.text        = txtSemester.Text;
                editBill.txtSchoolYear.text = txtSchoolYear.Text;
                editBill.calDueDate.Value   = DateTime.Parse(billDueDate);
                string comp = billStatus;
                if (comp == "false")
                {
                    editBill.cmbStatus.selectedIndex = 1;
                    editBill.calDatePaid.Enabled     = false;
                }
                else
                {
                    editBill.calDatePaid.Value       = DateTime.Parse(billDatePaid);
                    editBill.cmbStatus.selectedIndex = 0;
                    editBill.calDatePaid.Enabled     = true;
                }
                editBill.isEdit = true;
                editBill.ShowDialog();
                if (editBill.isConfirmed == true)
                {
                    var billManage = new BillManager();
                    var item       = new BillItem();

                    item.Bill_Discount    = Double.Parse(editBill.txtDiscount.text);
                    item.Bill_TotalAmount = Decimal.Parse(editBill.txtTotal.text);
                    item.Bill_FinalAmount = Decimal.Parse(editBill.txtFinal.text);
                    item.Bill_PaymentMade = Decimal.Parse(editBill.txtPayMade.text);
                    item.Bill_Balance     = Decimal.Parse(editBill.txtBalance.text);
                    item.Bill_Semester    = editBill.txtSem.text;
                    item.Bill_SchoolYear  = editBill.txtSchoolYear.text;
                    item.Bill_DueDate     = editBill.calDueDate.Value.ToString("MM/dd/yyyy");
                    item.Bill_Id          = billId;
                    if (editBill.cmbStatus.selectedIndex == 0)
                    {
                        item.Bill_Status   = "true";
                        item.Bill_DatePaid = editBill.calDatePaid.Value.ToString("MM/dd/yyyy");
                    }
                    else
                    {
                        item.Bill_Status   = "false";
                        item.Bill_DatePaid = "N/A";
                    }
                    billManage.UpdateBill(item);
                }
            }
            StdClick();
        }
예제 #27
0
        public async Task <IActionResult> Post(BillItem billItem)
        {
            if (billItem == null)
            {
                return(BadRequest(StatusCodes.Status400BadRequest));
            }
            BillItemRepository.Add(billItem);
            await UnitOfWork.SaveAsync();

            return(Ok(new { Code = 200 }));
        }
예제 #28
0
        private void AddItem()
        {
            var billItem = new BillItem {
                Position = this.BillItemDetailViewModels.Count + 1, Amount = 1
            };
            var billItemDetailViewModel = new BillItemDetailViewModel(billItem, this._repository);

            this._currentBill.AddBillItem(billItem);
            this.BillItemDetailViewModels.Add(billItemDetailViewModel);
            Messenger.Default.Send(new NotificationMessage(Resources.Message_FocusBillItemsMessageForBillItemEditView));
        }
예제 #29
0
        public SmsSimpleReport(IDialogService dialogService, BillItem bill)
        {
            if (bill == null || dialogService == null)
            {
                throw new ArgumentNullException();
            }

            _dialogService = dialogService;

            _bill = bill.Clone() as BillItem;
        }
    private void dgv_ItemNamePOS_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
    {
        string a = dgv_ItemNamePOS.CurrentRow.Cells[0].Value.ToString();

        dgv_POS.Rows[0].Cells[1].Value = a.ToString();
        BillItem billItem = _Items.First(item => item.ItemName == a);

        dgv_POS.Rows[0].Cells[0].Value = billItem.No.ToString();
        dgv_POS.Rows[0].Cells[2].Value = billItem.Code.ToString();
        dgv_POS.Rows[0].Cells[3].Value = billItem.MRP;
    }
예제 #31
0
        /// <summary>
        /// Retrieves and Updates bill of materials
        /// </summary>
        /// <param name="BillItems"></param>
        /// <param name="BillQty"></param>
        private void Setbill(List<BillItem>Bill)
        {
            List<bool> FindItemEpicor = new List<bool>();

            List<bool> FindItemSldWrks = new List<bool>();

            List<BillItem> AddBack = new List<BillItem>();

            List<string> AddBack_Opts = new List<string>();

            List<string> AddBack_Ops = new List<string>();

            List<string> AddBack_Uom = new List<string>();

            #region Locate items

            //See if the part exists in the SolidWorks data
            for (int i = 0; i < Bill.Count; i++)
            {FindItemSldWrks.Add(false);}

            //See if the part exists in the Epicor data
            for (int i = 0; i < EngWBDS.Tables["ECOMtl"].Rows.Count; i++)
            {
                FindItemEpicor.Add(false);

                BillItem Item = new BillItem();

                Item.PartNumber = EngWBDS.Tables["ECOMtl"].Rows[i]["MtlPartNum"].ToString();

                Item.Qty = EngWBDS.Tables["ECOMtl"].Rows[i]["QtyPer"].ToString();

                AddBack.Add(Item);

                //AddBack.Add(EngWBDS.Tables["ECOMtl"].Rows[i]["MtlPartNum"].ToString());

                //AddBack_Qty.Add(EngWBDS.Tables["ECOMtl"].Rows[i]["QtyPer"].ToString());

                AddBack_Ops.Add(EngWBDS.Tables["ECOMtl"].Rows[i]["RelatedOperation"].ToString());

                AddBack_Uom.Add(EngWBDS.Tables["ECOMtl"].Rows[i]["UOMCode"].ToString());
            }

            for (int i = 0; i < Bill.Count; i++)
            {
                for (int j = 0; j < EngWBDS.Tables["ECOMtl"].Rows.Count; j++)
                {
                    string DS_val = EngWBDS.Tables["ECOMtl"].Rows[j]["MtlPartNum"].ToString();

                    if (DS_val == Bill[i].PartNumber)
                        FindItemSldWrks[i] = true;
                }
            }

            for (int i = 0; i < EngWBDS.Tables["ECOMtl"].Rows.Count; i++)
            {
                for (int j = 0; j < Bill.Count; j++)
                {
                    if (EngWBDS.Tables["ECOMtl"].Rows[i]["MtlPartNum"].ToString() == Bill[j].PartNumber)
                        FindItemEpicor[i] = true;
                }
            }
            #endregion

            #region Determine what needs to be saved

            AddBack = SafeParts(AddBack, AddBack_Ops,AddBack_Uom, out AddBack_Opts, out AddBack_Ops, out AddBack_Uom);

            #endregion

            #region Delete Missing Items
            for (int i = EngWBDS.Tables["ECOMtl"].Rows.Count - 1; i > -1; i--)
            {
                if (!FindItemEpicor[i])
                {
                    //Remove items
                    EngWBDS.Tables["ECOMtl"].Rows[i].Delete();

                    EngWB.Update(EngWBDS);

                    EngWBDS = EngWB.GetDatasetForTree(gid_txt.Text, parent_txt.Text, parentrev_txt.Text, "", null, false, false);
                }
            }
            #endregion

            int rowmod = EngWBDS.Tables["ECOMtl"].Rows.Count;

            #region Add missing items

            try
            {
                for (int i = 0; i < Bill.Count; i++)
                {
                    if (!FindItemSldWrks[i])
                    {
                        try
                        {
                            //rowmod = EngWBDS.Tables["ECOMtl"].Rows.Count;
                            //Add item
                            EngWB.GetNewECOMtl(EngWBDS, gid_txt.Text, parent_txt.Text, parentrev_txt.Text, "");

                            EngWBDS.Tables["ECOMtl"].Rows[EngWBDS.Tables["ECOMtl"].Rows.Count-1]["MtlPartNum"] = Bill[i].PartNumber;

                            EngWBDS.Tables["ECOMtl"].Rows[EngWBDS.Tables["ECOMtl"].Rows.Count-1]["QtyPer"] = Bill[i].Qty;

                            EngWBDS.Tables["ECOMtl"].Rows[EngWBDS.Tables["ECOMtl"].Rows.Count-1]["RelatedOperation"] = ops_cbo.SelectedValue;

                            EngWBDS.Tables["ECOMtl"].Rows[EngWBDS.Tables["ECOMtl"].Rows.Count - 1]["OpDesc"] = EngWBDS.Tables["ECOOpr"].Rows[ops_cbo.SelectedIndex]["OpDesc"];

                            EngWBDS.Tables["ECOMtl"].Rows[EngWBDS.Tables["ECOMtl"].Rows.Count - 1]["PullAsAsm"] = false;

                            if (DataList.GetType(Bill[i].PartNumber) == "Purchased")
                                EngWBDS.Tables["ECOMtl"].Rows[EngWBDS.Tables["ECOMtl"].Rows.Count - 1]["ViewAsAsm"] = false;
                            else
                                EngWBDS.Tables["ECOMtl"].Rows[EngWBDS.Tables["ECOMtl"].Rows.Count - 1]["ViewAsAsm"] = true;

                            partnum_txt.Text = Bill[i].PartNumber;

                            DataTable ds = DataList.PartUOM(partnum_txt.Text);

                            uom_cbo.DataSource = ds;

                            uom_cbo.DisplayMember = "UOMCode";

                            uom_cbo.ValueMember = "UOMCode";

                            uom_cbo.SelectedIndex = 0;

                            EngWBDS.Tables["ECOMtl"].Rows[EngWBDS.Tables["ECOMtl"].Rows.Count - 1]["UOMCode"] = uom_cbo.SelectedValue;

                            decimal qty_val = decimal.Parse(Bill[i].Qty);

                            EngWBDS.Tables["ECOMtl"].Rows[EngWBDS.Tables["ECOMtl"].Rows.Count - 1]["QtyPer"] = qty_val;

                            EngWB.Update(EngWBDS);

                            EngWBDS = EngWB.GetDatasetForTree(gid_txt.Text, parent_txt.Text, parentrev_txt.Text, "", null, false, false);
                        }
                        catch { }
                    }
                }
            }
            catch  { }
            #endregion

            #region Add Saved items

            try
            {
                for (int i = 0; i < AddBack.Count; i++)
                {
                    rowmod = EngWBDS.Tables["ECOMtl"].Rows.Count;
                    //Add item
                    EngWB.GetNewECOMtl(EngWBDS, gid_txt.Text, parent_txt.Text, parentrev_txt.Text, "");

                    EngWBDS.Tables["ECOMtl"].Rows[rowmod]["MtlPartNum"] = AddBack[i];

                    EngWBDS.Tables["ECOMtl"].Rows[rowmod]["QtyPer"] = AddBack[i].Qty;

                    //EngWBDS.Tables["ECOMtl"].Rows[rowmod]["QtyPer"] = AddBack_Qty[i];

                    EngWBDS.Tables["ECOMtl"].Rows[rowmod]["RelatedOperation"] = AddBack_Ops[i];

                    EngWBDS.Tables["ECOMtl"].Rows[rowmod]["OpDesc"] = EngWBDS.Tables["ECOOpr"].Rows[ops_cbo.SelectedIndex]["OpDesc"];

                    char[] opts = AddBack_Opts[i].ToCharArray();

                    EngWBDS.Tables["ECOMtl"].Rows[rowmod]["ViewAsAsm"] = (opts[0] == '1' ? true : false);

                    EngWBDS.Tables["ECOMtl"].Rows[rowmod]["PullAsAsm"] = (opts[1] == '1' ? true : false);

                    partnum_txt.Text = AddBack[i].PartNumber;

                    DataTable ds = DataList.PartUOM(partnum_txt.Text);

                    uom_cbo.DataSource = ds;

                    uom_cbo.DisplayMember = "UOMCode";

                    uom_cbo.ValueMember = "UOMCode";

                    uom_cbo.SelectedIndex = 0;

                    EngWBDS.Tables["ECOMtl"].Rows[rowmod]["UOMCode"] = AddBack_Uom[i];

                    uom_cbo.Text = AddBack_Uom[i];

                    decimal qty_val = decimal.Parse(AddBack[i].Qty);

                    //decimal qty_val = decimal.Parse(AddBack_Qty[i]);

                    EngWBDS.Tables["ECOMtl"].Rows[rowmod]["QtyPer"] = qty_val;

                    EngWB.Update(EngWBDS);

                    EngWBDS = EngWB.GetDatasetForTree(gid_txt.Text, parent_txt.Text, parentrev_txt.Text, "", null, false, false);
                }
            }
            catch{}

            #endregion

            #region Update per line
            for (int i = 0; i < Bill.Count; i++)
            {
                for (int j = 0; j < EngWBDS.Tables["ECOMtl"].Rows.Count; j++)
                {
                    EngWBDS.Tables["ECOMtl"].Rows[j]["OpDesc"] = EngWBDS.Tables["ECOOpr"].Rows[((int.Parse(EngWBDS.Tables["ECOMtl"].Rows[j]["RelatedOperation"].ToString())/10)-1)]["OpDesc"];

                    string EpicValue = EngWBDS.Tables["ECOMtl"].Rows[j]["MtlPartNum"].ToString();

                    string _BillItem = Bill[i].PartNumber;

                    decimal EpicQty = decimal.Parse(EngWBDS.Tables["ECOMtl"].Rows[j]["QtyPer"].ToString());

                    decimal _BillQty = decimal.Parse(Bill[i].Qty);

                    if (EpicValue == _BillItem && EpicQty != _BillQty)
                    {
                        EngWBDS.Tables["ECOMtl"].Rows[j]["QtyPer"] = Bill[i].Qty;
                    }
                }
            }
            #endregion

            try
            {
                EngWB.Update(EngWBDS);

                EngWB.ResequenceMaterials(gid_txt.Text, parent_txt.Text, parentrev_txt.Text, "", null, false, Properties.Settings.Default.mtlreqtype, false, false, false);

                EngWBDS = EngWB.GetDatasetForTree(gid_txt.Text, parent_txt.Text, parentrev_txt.Text, "", null, false, false);

                BillDataGrid.DataSource = EngWBDS.Tables["ECOMtl"];

                EnableItemDetails();

            }
            catch { }
        }
예제 #32
0
        void BW_DoWorkDrawing(object sender, DoWorkEventArgs e)
        {
            object[] args = new object [2];

            args = (object[])e.Argument ;

            IEdmVault7 vault = (IEdmVault7)args[1];

            IEdmFile7 part = (IEdmFile7)args[0];

            Array bom_array;

            part.GetDerivedBOMs(out bom_array);

            EdmBomInfo[] BOMs = (EdmBomInfo[])bom_array;

            IEdmBom bom = (IEdmBom)vault.GetObject(EdmObjectType.EdmObject_BOM, BOMs[BOMs.GetUpperBound(0)].mlBomID);

            EdmBomView bomView = bom.GetView();

            Array BomVal;

            bomView.GetRows(out BomVal);

            Bill = null;

            List<string> BillLevel = new List<string>();

            ParentNumber = BOMs[0].mbsBomName;

            ParentNumber = ParentNumber.Substring(0, BOMs[0].mbsBomName.IndexOf(".SLDDRW"));

            for (int i = 0; i < BomVal.Length; i++)
            {
                IEdmBomCell bominfo = (IEdmBomCell)BomVal.GetValue(i);

                object Value;

                object Val_Qty;

                object CompVal;

                string Config;

                bool RO;

                bominfo.GetVar(0, EdmBomColumnType.EdmBomCol_RefCount, out Val_Qty, out CompVal, out Config, out RO);

                bominfo.GetVar(0, EdmBomColumnType.EdmBomCol_PartNumber, out Value, out CompVal, out Config, out RO);

                if (!Value.ToString().Contains("PART"))
                {
                    try
                    {
                        double QtyInt = double.Parse(Val_Qty.ToString());

                        BillItem Item = new BillItem();

                        Item.PartNumber = Value.ToString();

                        Item.Qty = Val_Qty.ToString();

                        Bill.Add(Item);
                    }
                    catch { }
                }
            }
        }
예제 #33
0
        void BW_DoWorkCalc(object sender, DoWorkEventArgs e)
        {
            object weight_val = "0";

            object area_val = "0";

            object[] args = new object[3];

            args = (object[])e.Argument;

            IEdmVault7 vault = (IEdmVault7)args[1];

            IEdmFile7 part = (IEdmFile7)args[0];

            string selected_config = args[2].ToString();

            IEdmEnumeratorVariable5 var = part.GetEnumeratorVariable();

            #region Fill Bill

            IEdmBomMgr BomMgr = (IEdmBomMgr)vault.CreateUtility(EdmUtility.EdmUtil_BomMgr);

            Array LayoutVal;

            Array BomVal = Array.CreateInstance(typeof(EdmBomInfo), 1);

            Array ColumnVal;

            BomMgr.GetBomLayouts(out LayoutVal);

            IEdmBomMgr EdmBomMgr = (IEdmBomMgr)vault.CreateUtility(EdmUtility.EdmUtil_BomMgr);

            Array BomLayouts;

            EdmBomMgr.GetBomLayouts(out BomLayouts);

            //selected_config = something;

            EdmBomView BomView = part.GetComputedBOM(1, 0, selected_config, 2);

            BomView.GetRows(out BomVal);

            BomView.GetColumns(out ColumnVal);

            EdmBomColumn ColVal = (EdmBomColumn)ColumnVal.GetValue(0);

            List<string> BillLevel = new List<string>();

            string PConfig = "";

            for (int i = 0; i < BomVal.Length; i++)
            {
                IEdmBomCell bominfo = (IEdmBomCell)BomVal.GetValue(i);

                object QtyValue;

                object PnumValue;

                object FnameValue;

                object ConfValue;

                object ParentConfig;

                object CalcType;

                object Name;

                object CompVal;

                string Config;

                bool RO;

                int itemlevel = bominfo.GetTreeLevel();

                if (itemlevel == 0)
                {
                    bominfo.GetVar(0, EdmBomColumnType.EdmBomCol_PartNumber, out PnumValue, out CompVal, out Config, out RO);

                    ParentNumber = PnumValue.ToString();

                    bominfo.GetVar(0, EdmBomColumnType.EdmBomCol_Configuration, out ParentConfig, out CompVal, out Config, out RO);

                    PConfig = ParentConfig.ToString();
                }

                if (itemlevel == 1)
                {

                    bominfo.GetVar(0, EdmBomColumnType.EdmBomCol_RefCount, out QtyValue, out CompVal, out Config, out RO);

                    bominfo.GetVar(0, EdmBomColumnType.EdmBomCol_PartNumber, out PnumValue, out CompVal, out Config, out RO);

                    if (PnumValue.ToString() == PConfig)
                    {
                        bominfo.GetVar(0, EdmBomColumnType.EdmBomCol_Configuration, out ConfValue, out CompVal, out Config, out RO);

                        bominfo.GetVar(0, EdmBomColumnType.EdmBomCol_Name, out FnameValue, out CompVal, out Config, out RO);

                        IEdmFile7 subpart = FindPartinVault(vault, FnameValue.ToString(), ConfValue.ToString());

                        EdmBomView SubBomView = subpart.GetComputedBOM(1, 0, ConfValue.ToString(), 2);

                        Array SubBomVal = Array.CreateInstance(typeof(EdmBomInfo), 1);

                        Array SubColumnVal;

                        SubBomView.GetRows(out SubBomVal);

                        SubBomView.GetColumns(out SubColumnVal);

                        for (int j = 0; j < SubBomVal.Length; j++)
                        {
                            IEdmBomCell subbominfo = (IEdmBomCell)SubBomVal.GetValue(j);

                            int subitemlevel = subbominfo.GetTreeLevel();

                            if (subitemlevel == 1)
                            {
                                object QtyValue2;

                                subbominfo.GetVar(0, EdmBomColumnType.EdmBomCol_RefCount, out QtyValue2, out CompVal, out Config, out RO);

                                subbominfo.GetVar(0, EdmBomColumnType.EdmBomCol_PartNumber, out PnumValue, out CompVal, out Config, out RO);

                                if (PnumValue == "")
                                    subbominfo.GetVar(0, EdmBomColumnType.EdmBomCol_Configuration, out PnumValue, out CompVal, out Config, out RO);

                                subbominfo.GetVar(0, EdmBomColumnType.EdmBomCol_Name, out Name, out CompVal, out Config, out RO);

                                BillItem Item = new BillItem();

                                QtyValue2 = decimal.Parse(QtyValue.ToString()) * decimal.Parse(QtyValue2.ToString());

                                Item.Qty = QtyValue2.ToString();

                                Item.PartNumber = PnumValue.ToString();

                                Bill.Add(Item);
                            }
                        }
                    }
                    else
                    {
                        BillItem Item = new BillItem();

                        Item.Qty = QtyValue.ToString();

                        Item.PartNumber = PnumValue.ToString();

                        Bill.Add(Item);
                    }

                }

                bominfo.GetVar(0, EdmBomColumnType.EdmBomCol_PartNumber, out PnumValue, out CompVal, out Config, out RO);

                bominfo.GetVar(0, EdmBomColumnType.EdmBomCol_Name, out Name, out CompVal, out Config, out RO);

                Debug.Print(PnumValue.ToString() + "\t" + itemlevel.ToString() + "\t" + Name.ToString());

            }
            #endregion

            if (BW.IsBusy)
                BW.CancelAsync();
        }
예제 #34
0
        /// <summary>
        /// Finds current safe parts within the current bill of materials and keeps a separate list of them to add after the bom has been updated (Sheets/Coils/E-Coat)
        /// </summary>
        /// <param name="BillParts">Current Epicor Bill of Materials</param>
        /// <param name="BillQty">Current Epicor Bill of Materials Qty</param>
        /// <param name="Bill_Qty">Bill of Materials Qty for only Safe items</param>
        /// <returns>Bill of Materials for only safe items</returns>
        public List<BillItem> SafeParts(List<BillItem> BillParts,List <string> BillOps, List<string> BillUOM, out List<string> BillOpts, out List<string> Bill_Ops, out List<string>Bill_UOM)
        {
            //out List<string> Bill_Qty, , List<string> BillQty

            List<BillItem> RetVal = new List<BillItem>();

            //List<string> RetVal_Qty = new List<string>();

            List<string> RetVal_Ops = new List<string>();

            List<string> RetVal_UOM = new List<string>();

            BillOpts = new List<string>();

            List<RawMaterial> ListtoSave = new List<RawMaterial>();

            ListtoSave.AddRange(DataList.GetCoils());

            ListtoSave.AddRange(DataList.GetEcoat());

            ListtoSave.AddRange(DataList.GetSheets());

            for (int i = 0; i < BillParts.Count; i++)
            {
                string view = (EngWBDS.Tables["ECOMtl"].Rows[i]["ViewAsAsm"].ToString() == "True" ? "1" : "0");

                string pull = (EngWBDS.Tables["ECOMtl"].Rows[i]["PullAsAsm"].ToString() == "True" ? "1" : "0");

                for (int j = 0; j < ListtoSave.Count; j++)
                {
                    if (BillParts[i].PartNumber == ListtoSave[j].part_number)
                    {
                        BillItem Item = new BillItem();

                        Item.PartNumber = BillParts[i].PartNumber;

                        Item.Qty = BillParts[i].Qty;

                        RetVal.Add(Item);

                        //RetVal_Qty .Add(BillParts[i].Qty);

                        BillOpts.Add(view + pull);

                        RetVal_Ops.Add(BillOps[i]);

                        RetVal_UOM.Add(EngWBDS.Tables["ECOMtl"].Rows[i]["UOMCode"].ToString());
                    }
                }
            }

            Bill_Ops = RetVal_Ops;

            //Bill_Qty = RetVal_Qty;

            Bill_UOM = RetVal_UOM;

            return RetVal;
        }