Example #1
0
    private void AddReceiptItem(Product product, ReceiptItem receiptItem)
    {
        String productName = String.Empty;

        if (receiptItem.ProductId.HasValue)
        {
            product = ProductManager.GetProduct(receiptItem.ProductId.Value, Company.CompanyId);
        }

        if (product != null)
        {
            receiptItem.ICMS = product.ICMS;
            receiptItem.IPI  = product.IPI;
            productName      = product.Name;
        }

        var productItem = new ReceiptItem();

        productItem.ReceiptItemId = receiptItem.ReceiptItemId;
        productItem.ReceiptId     = receiptItem.ReceiptId;
        productItem.UnitPrice     = receiptItem.UnitPrice;
        productItem.Quantity      = Convert.ToInt32(receiptItem.Quantity);
        productItem.IPI           = receiptItem.IPI;
        productItem.ICMS          = receiptItem.ICMS;
        productItem.ProductId     = receiptItem.ProductId;
        productItem.Description   = !String.IsNullOrEmpty(productName)
                                      ? productName
                                      : receiptItem.Description;
        ReceiptItems.Add(productItem);

        CalculateTotal(GetReceiptItemTotalValue(productItem, 1));
    }
Example #2
0
    protected void grdReceiptItem_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        //
        // Recalcula o total e Remove a linha da lista em memória
        //
        CalculateTotal(-GetReceiptItemTotalValue(ReceiptItems[e.RowIndex], -1));
        ReceiptItems.RemoveAt(e.RowIndex);

        //
        // Atualiza a grid já sem o item removido
        //
        BindReceiptItems();
    }
        public void RemoveReceiptItem(int ReceiptItemID)
        {
            int i     = 0;
            int index = 0;

            foreach (ReceiptItem ri in ReceiptItems)
            {
                if (ri.ReceiptItemID == ReceiptItemID)
                {
                    index = i;
                    break;
                }
                i++;
            }
            ReceiptItems.RemoveAt(index);
        }
        IList <ReceiptFieldUI> GetReceiptFieldsUI(ReceiptItems items)
        {
            var fields = new List <ReceiptFieldUI>();

            if (items?.ValueArray != null)
            {
                foreach (ReceiptItemValue item in items.ValueArray.Where(i => i.ValueObject != null))
                {
                    fields.Add(new ReceiptFieldUI()
                    {
                        Quantity   = GetReceiptItemUI(item.ValueObject.Quantity),
                        Name       = GetReceiptItemUI(item.ValueObject.Name),
                        TotalPrice = GetReceiptItemUI(item.ValueObject.TotalPrice),
                    });
                }
            }
            return(fields);
        }
Example #5
0
    private void AddReceiptItem(Service service, ReceiptItem receiptItem)
    {
        var serviceItem = new ReceiptItem();

        serviceItem.ReceiptItemId = receiptItem.ReceiptItemId;
        serviceItem.CompanyId     = receiptItem.CompanyId;
        serviceItem.ServiceId     = receiptItem.ServiceId;
        serviceItem.UnitPrice     = receiptItem.UnitPrice;
        serviceItem.Quantity      = 1;
        serviceItem.ProductId     = receiptItem.ProductId;
        serviceItem.IPI           = receiptItem.IPI;
        serviceItem.ICMS          = receiptItem.ICMS;
        serviceItem.Description   = !String.IsNullOrEmpty(service.Name)
                                      ? service.Name
                                      : receiptItem.Description;
        ReceiptItems.Add(serviceItem);

        CalculateTotal(GetReceiptItemTotalValue(serviceItem, 1));
    }
        public async Task Refresh()
        {
            _receiptItems.Clear();
            _goodsItems.Clear();

            List <AlbumItem> receipts = await _azure.GetAllImages(CurrentTransaction.ID, true);

            foreach (AlbumItem t in receipts)
            {
                Receipts.Add(t);
            }

            receipts.Add(new AlbumItem {
                IsAddButton = true, IsReceipt = true
            });
            int            i       = 0;
            ImageListItems tempILI = new ImageListItems();

            foreach (AlbumItem t in receipts)
            {
                //RESET temp class for next ListEntry
                if (tempILI == null)
                {
                    tempILI = new ImageListItems();
                }

                //Add Image
                tempILI.ItemImages.Add(t);

                //Add ListEntry content and reset for next Entry
                if (i >= 3)
                {
                    ReceiptItems.Add(tempILI);
                    tempILI = null;
                    i       = 0;
                }
                i++;
            }

            //Fill aditional spaces with filler image
            if (tempILI != null)
            {
                for (int j = tempILI.ItemImages.Count; j < 3; j++)
                {
                    tempILI.ItemImages.Add(new AlbumItem());
                }
                ReceiptItems.Add(tempILI);
            }

            //Reset Values to refresh Goods
            tempILI = null;
            i       = 0;


            List <AlbumItem> goods = await _azure.GetAllImages(CurrentTransaction.ID, false);

            foreach (AlbumItem t in goods)
            {
                Goods.Add(t);
            }

            goods.Add(new AlbumItem {
                IsAddButton = true, IsReceipt = false
            });
            foreach (AlbumItem t in goods)
            {
                if (tempILI == null)
                {
                    tempILI = new ImageListItems();
                }

                tempILI.ItemImages.Add(t);
                if (i >= 3)
                {
                    GoodsItems.Add(tempILI);
                    tempILI = null;
                    i       = 0;
                }
                i++;
            }

            //Fill aditional spaces with filler image
            if (tempILI != null)
            {
                for (int j = tempILI.ItemImages.Count; j < 3; j++)
                {
                    tempILI.ItemImages.Add(new AlbumItem());
                }
                GoodsItems.Add(tempILI);
            }
            HockeyApp.MetricsManager.TrackEvent("Images Page Loaded");
        }
 public void AddItem(Item item, decimal itemTax, decimal itemTotalPrice)
 {
     ReceiptItems.Add(new ItemReceipt(item, itemTotalPrice));
     SalesTax += itemTax;
     Total    += itemTax + item.BasePrice;
 }
Example #8
0
        //删除入库单
        public static void DelRKD(int i_ReceiptID)
        {
            ISession     session = NHibernateHelper.sessionFactory.OpenSession();
            ITransaction tx      = session.BeginTransaction();

            try
            {
                Receipt toDel1 = session.Get <Receipt>(i_ReceiptID);

                //更新未付款
                //如果原应付款不为0,则删除AccountBill表的相关数据,并更新WareHouseStock表中的相关数据
                if (toDel1.ReceiptDiscAmt != 0)
                {
                    AccountBill tAB = BLL.AccountBillBLL.GetAccountBill(toDel1.ProjectID, toDel1.CompanyID, 100, "采购应付款" + toDel1.ReceiptNum);
                    if (tAB.BillNo == 0)
                    {
                        tx.Rollback();
                        session.Close();
                        MessageBox.Show("没有找到可以删除的入库单生成的应付款记录!请检查数据库!", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    AccountBill toDelete = session.Get <AccountBill>(tAB.BillNo);
                    session.Delete(toDelete);
                }
                //删除ReceiptItem中的相关项
                List <int> toDelItemsID = BLL.RKBLL.GetItemIDs(toDel1.ReceiptID);
                foreach (int i in toDelItemsID)
                {
                    ReceiptItems toDel2 = session.Get <ReceiptItems>(i);
                    session.Delete(toDel2);
                    //更新库存
                    PKModel pk = new PKModel();
                    pk.GoodsID     = toDel2.GoodsID;
                    pk.WareHouseID = toDel1.WareHouseID;
                    WareHouseStock tWH = session.Get <WareHouseStock>(pk);
                    if (tWH != null)
                    {
                        tWH.Number -= toDel2.GoodsQty;
                        tWH.Amount -= toDel2.GoodsAmt;
                        if (tWH.Number != 0)
                        {
                            tWH.Price = Math.Round(tWH.Amount / tWH.Number, 2);
                        }
                        else
                        {
                            tWH.Price = 0;
                        }
                    }
                }
                session.Delete(toDel1);
                //事务提交
                tx.Commit();
                session.Close();
            }
            catch (Exception e)
            {
                Debug.Assert(false, e.Message);
                tx.Rollback();
                session.Close();
            }
        }
Example #9
0
        //修改入库单
        public static void ModifyRKD(Receipt tReceipt, List <ReceiptItems> tItemsList)
        {
            //修改入库单
            ISession     session = NHibernateHelper.sessionFactory.OpenSession();
            ITransaction tx      = session.BeginTransaction();

            try
            {
                //得到未变更的入库单
                Receipt tOldReceipt = new Receipt();
                tOldReceipt = BLL.RKBLL.GetReceipt(tReceipt.ReceiptID);
                //如果原应付款不为0,则删除AccountBill表的相关数据,并更新Companies表中的相关数据
                if (tOldReceipt.ReceiptDiscAmt != 0)
                {
                    AccountBill tAB = BLL.AccountBillBLL.GetAccountBill(tOldReceipt.ProjectID, tOldReceipt.CompanyID, 100, "采购应付款" + tOldReceipt.ReceiptNum);
                    if (tAB.BillNo == 0)
                    {
                        tx.Rollback();
                        session.Close();
                        MessageBox.Show("没有找到可以删除的入库单生成的应付款记录!请检查数据库!", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    AccountBill toDelete = session.Get <AccountBill>(tAB.BillNo);
                    session.Delete(toDelete);
                }
                //删除ReceiptItem中的相关项
                List <int> toDelItemsID = BLL.RKBLL.GetItemIDs(tOldReceipt.ReceiptID);
                foreach (int i in toDelItemsID)
                {
                    ReceiptItems toDel1 = session.Get <ReceiptItems>(i);
                    session.Delete(toDel1);
                    //更新库存
                    PKModel pk = new PKModel();
                    pk.GoodsID     = toDel1.GoodsID;
                    pk.WareHouseID = tOldReceipt.WareHouseID;
                    WareHouseStock tWH = session.Get <WareHouseStock>(pk);
                    if (tWH == null)
                    {
                        WareHouseStock tWHNew = new WareHouseStock();
                        tWHNew.Pk = pk;

                        tWHNew.Number = toDel1.GoodsQty;
                        tWHNew.Price  = toDel1.GoodsPrc;
                        tWHNew.Amount = toDel1.GoodsAmt;
                        session.Save(tWHNew);
                    }
                    else
                    {
                        tWH.Number -= toDel1.GoodsQty;
                        tWH.Amount -= toDel1.GoodsAmt;
                        if (tWH.Number != 0)
                        {
                            tWH.Price = Math.Round(tWH.Amount / tWH.Number, 2);
                        }
                        session.Flush();
                    }
                }
                //保存Receipt的修改
                Receipt toModify = session.Get <Receipt>(tOldReceipt.ReceiptID);
                toModify.CompanyID      = tReceipt.CompanyID;
                toModify.ProjectID      = tReceipt.ProjectID;
                toModify.ReceiptType    = tReceipt.ReceiptType;
                toModify.ReceiptBillAmt = tReceipt.ReceiptBillAmt;
                toModify.ReceiptDisc    = tReceipt.ReceiptDisc;
                toModify.ReceiptDiscAmt = tReceipt.ReceiptDiscAmt;
                toModify.PurchName      = tReceipt.PurchName;
                toModify.ReceiverName   = tReceipt.ReceiverName;
                toModify.RecordStatus   = "已记账";
                toModify.Remark         = tReceipt.Remark;
                toModify.WareHouseID    = tReceipt.WareHouseID;


                //将新的ReceiptItem加入
                foreach (ReceiptItems tRI in tItemsList)
                {
                    tRI.ReceiptID = tReceipt.ReceiptID;
                    session.Save(tRI);
                    //更新库存
                    PKModel pk = new PKModel();
                    pk.GoodsID     = tRI.GoodsID;
                    pk.WareHouseID = tReceipt.WareHouseID;
                    WareHouseStock tWH = session.Get <WareHouseStock>(pk);
                    if (tWH == null)
                    {
                        WareHouseStock tWHNew = new WareHouseStock();
                        tWHNew.Pk = pk;

                        tWHNew.Number = tRI.GoodsQty;
                        tWHNew.Price  = tRI.GoodsPrc;
                        tWHNew.Amount = tRI.GoodsAmt;
                        session.Save(tWHNew);
                    }
                    else
                    {
                        tWH.Number += tRI.GoodsQty;
                        tWH.Amount += tRI.GoodsAmt;
                        if (tWH.Number != 0)
                        {
                            tWH.Price = Math.Round(tWH.Amount / tWH.Number, 2);
                        }
                        session.Flush();
                    }
                }
                //根据应付款是否为0添加AccountBill记录及更新Companies表
                if (tReceipt.ReceiptDiscAmt != 0)
                {
                    Projects    tP1  = session.Get <Projects>(tReceipt.ProjectID);
                    Companies   tC1  = session.Get <Companies>(tReceipt.CompanyID);
                    AccountBill tAcc = new AccountBill();
                    tAcc.CompanyID     = tReceipt.CompanyID;
                    tAcc.CompanyName   = tC1.CompanyName;
                    tAcc.BillDate      = tReceipt.ReceiptDate;
                    tAcc.BillMemo      = "采购应付款" + tReceipt.ReceiptNum;
                    tAcc.BillType      = 1;
                    tAcc.BillYF        = tReceipt.ReceiptDiscAmt;
                    tAcc.ProjectID     = tReceipt.ProjectID;
                    tAcc.ProjectName   = tP1.ProjectName;
                    tAcc.MoneyTypeID   = 100;                     //材料购买
                    tAcc.MoneyTypeName = "入库单生成";
                    tAcc.BillStatus    = "已记账";
                    session.Save(tAcc);
                }

                //事务提交
                tx.Commit();
                session.Close();
            }
            catch (Exception e)
            {
                Debug.Assert(false, e.Message);
                tx.Rollback();
                session.Close();
            }
        }
Example #10
0
        //增加入库单
        public static void AddRKD(Receipt tReceipt, List <ReceiptItems> tItemsList)
        {
            //保存数据,注意使用事务进行处理
            //1、入库单号的生成与修改;2、入库单的增加;3入库单项目的增加
            ISession     session = NHibernateHelper.sessionFactory.OpenSession();
            ITransaction tx      = session.BeginTransaction();

            try
            {
                //查最后的入库单号
                IList <ProgOptions> Key1 = BLL.ProgOptionsBLL.GetOptions("RKD_LastNumber");
                string s_RKD_LastNo      = Key1[0].OptionsValue;
                string s_RKD_NewNo;
                string s_RKD_LastYM;
                string s_RKD_NewYM;
                int    LastNo;
                int    NewNo;
                string s_NewNo;
                s_RKD_NewYM = DateTime.Today.ToString("yyyyMM");
                if (s_RKD_LastNo.Length == 10)
                {
                    //4位年+2位月+4位顺序号
                    s_RKD_LastYM = s_RKD_LastNo.Substring(0, 6);
                    LastNo       = Convert.ToInt32(s_RKD_LastNo.Substring(6, 4));
                    if (s_RKD_NewYM != s_RKD_LastYM)
                    {
                        NewNo = 1;
                    }
                    else
                    {
                        NewNo = LastNo + 1;
                    }
                }
                else
                {
                    //没有数据
                    NewNo = 1;
                }
                s_NewNo = "0000" + NewNo.ToString();
                s_NewNo = s_NewNo.Substring(s_NewNo.Length - 4, 4);
                //将新的最后编号保存到数据库
                ProgOptions t1 = session.Get <ProgOptions>(Key1[0].OptionsID);
                t1.OptionsID     = Key1[0].OptionsID;
                t1.OptionsKey    = Key1[0].OptionsKey;
                s_RKD_NewNo      = s_RKD_NewYM + s_NewNo;
                t1.OptionsValue  = s_RKD_NewNo;
                t1.OptionsRemark = Key1[0].OptionsRemark;

                //保存入库单
                tReceipt.ReceiptNum = "RKD-" + t1.OptionsValue;
                session.Save(tReceipt);

                //添加应付款

                if (tReceipt.ReceiptDiscAmt != 0)
                {
                    Projects    tP1  = session.Get <Projects>(tReceipt.ProjectID);
                    Companies   tC1  = session.Get <Companies>(tReceipt.CompanyID);
                    AccountBill tAcc = new AccountBill();
                    tAcc.CompanyID     = tReceipt.CompanyID;
                    tAcc.CompanyName   = tC1.CompanyName;
                    tAcc.BillDate      = tReceipt.ReceiptDate;
                    tAcc.BillMemo      = "采购应付款" + tReceipt.ReceiptNum;
                    tAcc.BillType      = 1;
                    tAcc.BillYF        = tReceipt.ReceiptDiscAmt;
                    tAcc.ProjectID     = tReceipt.ProjectID;
                    tAcc.ProjectName   = tP1.ProjectName;
                    tAcc.MoneyTypeID   = 100;                     //材料购买
                    tAcc.MoneyTypeName = "入库单生成";
                    tAcc.BillStatus    = "已记账";
                    session.Save(tAcc);
                }

                foreach (ReceiptItems tRI in tItemsList)
                {
                    //保存进货项
                    ReceiptItems tNewReceiptItems = new ReceiptItems();
                    tNewReceiptItems.GoodsID         = tRI.GoodsID;
                    tNewReceiptItems.ReceiptID       = tReceipt.ReceiptID;
                    tNewReceiptItems.GoodsName       = tRI.GoodsName;
                    tNewReceiptItems.GoodsAmt        = tRI.GoodsAmt;
                    tNewReceiptItems.GoodsPlan       = tRI.GoodsPlan;
                    tNewReceiptItems.GoodsPlanNo     = tRI.GoodsPlanNo;
                    tNewReceiptItems.GoodsPrc        = tRI.GoodsPrc;
                    tNewReceiptItems.GoodsQty        = tRI.GoodsQty;
                    tNewReceiptItems.GoodsSpec       = tRI.GoodsSpec;
                    tNewReceiptItems.GoodsUnit       = tRI.GoodsUnit;
                    tNewReceiptItems.GoodsYF         = tRI.GoodsYF;
                    tNewReceiptItems.GoodsTaxRate    = tRI.GoodsTaxRate;
                    tNewReceiptItems.GoodsNoTaxPrice = tRI.GoodsNoTaxPrice;
                    tNewReceiptItems.MoreSpec        = tRI.MoreSpec;
                    tNewReceiptItems.UsePosition     = tRI.UsePosition;

                    session.Save(tNewReceiptItems);
                }

                //入库单同货品合并
                List <ReceiptItems> mergeList = new List <ReceiptItems>();
                foreach (ReceiptItems tRI in tItemsList)
                {
                    ReceiptItems rtnRItem = mergeList.Find(name =>
                    {
                        if (name.GoodsID == tRI.GoodsID)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    });
                    if (rtnRItem == null)
                    {
                        mergeList.Add(tRI);
                    }
                    else
                    {
                        rtnRItem.GoodsQty += tRI.GoodsQty;
                        rtnRItem.GoodsAmt += tRI.GoodsAmt;
                        if (rtnRItem.GoodsQty != 0)
                        {
                            rtnRItem.GoodsPrc = rtnRItem.GoodsAmt / rtnRItem.GoodsQty;
                        }
                    }
                }

                //更新库存
                foreach (ReceiptItems tRI in mergeList)
                {
                    PKModel pk = new PKModel();
                    pk.GoodsID     = tRI.GoodsID;
                    pk.WareHouseID = tReceipt.WareHouseID;
                    WareHouseStock tWH = session.Get <WareHouseStock>(pk);
                    if (tWH == null)
                    {
                        WareHouseStock tWHNew = new WareHouseStock();
                        tWHNew.Pk = pk;

                        tWHNew.Number    = tRI.GoodsQty;
                        tWHNew.LastPrice = tRI.GoodsPrc;
                        tWHNew.Price     = tRI.GoodsPrc;
                        tWHNew.Amount    = tRI.GoodsAmt;
                        session.Save(tWHNew);
                    }
                    else
                    {
                        tWH.Number   += tRI.GoodsQty;
                        tWH.Amount   += tRI.GoodsAmt;
                        tWH.LastPrice = tRI.GoodsPrc;
                        if (tWH.Number != 0)
                        {
                            tWH.Price = Math.Round(tWH.Amount / tWH.Number, 2);
                        }
                        session.Flush();
                    }
                }
                //事务提交
                tx.Commit();
                session.Close();
            }
            catch (Exception e)
            {
                Debug.Assert(false, e.Message);
                tx.Rollback();
                session.Close();
            }
        }
Example #11
0
        void AddNewReceipt()
        {
            //保存数据,注意使用事务进行处理
            //1、入库单号的生成与修改;2、入库单的增加;3入库单项目的增加
            Receipt tR = new Receipt();

            tR.ReceiptDate = dateTimePickerRKDate.Value;
            tR.ProjectID   = Convert.ToInt32(comboBoxProjectID.SelectedValue.ToString());
            tR.CompanyID   = Convert.ToInt32(comboBoxCompanyID.SelectedValue.ToString());
            tR.WareHouseID = Convert.ToInt32(comboBoxWareHouseID.SelectedValue.ToString());
            string tS1           = comboBoxReceiptType.Text;
            int    i_ReceiptType = 0;

            switch (tS1)
            {
            case "采购入库":
                i_ReceiptType = 0;
                break;

            case "采购退货":
                i_ReceiptType = 1;
                break;

            case "调拨入库":
                i_ReceiptType = 2;
                break;

            case "调拨退货":
                i_ReceiptType = 3;
                break;

            case "报溢入库":
                i_ReceiptType = 4;
                break;

            case "报溢退货":
                i_ReceiptType = 5;
                break;

            default:
                break;
            }
            tR.ReceiptType    = i_ReceiptType;
            tR.ReceiptBillAmt = dTotal;
            tR.ReceiptDiscAmt = Convert.ToDecimal(textBoxPayDiscAmt.Text == "" ? "0" : textBoxPayDiscAmt.Text);
            tR.ReceiptDisc    = Convert.ToDecimal(textBoxDisc.Text == "" ? "100" : textBoxDisc.Text) / 100;
            tR.Remark         = waterTextBoxRemark.Text;
            tR.PurchName      = textBoxPurcher.Text;
            tR.ReceiverName   = textBoxReceriver.Text;
            tR.RecordStatus   = "已记账";
            List <ReceiptItems> tItems = new List <ReceiptItems>();

            int row = dataGridView1.Rows.Count;            //得到总行数

            for (int i = 0; i < row - 1; i++)
            {
                //最后一行是新行,不算
                ReceiptItems tItem;
                tItem                 = new ReceiptItems();
                tItem.GoodsID         = Convert.ToInt32(dataGridView1.Rows[i].Cells["GoodsID"].Value);
                tItem.GoodsQty        = Convert.ToDecimal(dataGridView1.Rows[i].Cells["GoodsQty"].Value);
                tItem.GoodsPrc        = Convert.ToDecimal(dataGridView1.Rows[i].Cells["GoodsPrc"].Value);
                tItem.GoodsYF         = Convert.ToDecimal(dataGridView1.Rows[i].Cells["GoodsYF"].Value);
                tItem.GoodsAmt        = Convert.ToDecimal(dataGridView1.Rows[i].Cells["GoodsAmt"].Value);
                tItem.GoodsTaxRate    = Convert.ToDecimal(dataGridView1.Rows[i].Cells["GoodsTaxRate"].Value);
                tItem.GoodsNoTaxPrice = Convert.ToDecimal(dataGridView1.Rows[i].Cells["GoodsNoTaxPrice"].Value);
                tItem.GoodsName       = dataGridView1.Rows[i].Cells["GoodsName"].Value.ToString();
                tItem.GoodsSpec       = dataGridView1.Rows[i].Cells["GoodsSpec"].Value.ToString();
                tItem.MoreSpec        = dataGridView1.Rows[i].Cells["MoreSpec"].Value.ToString();
                tItem.GoodsUnit       = dataGridView1.Rows[i].Cells["GoodsUnit"].Value.ToString();
                tItem.UsePosition     = dataGridView1.Rows[i].Cells["UsePosition"].Value.ToString();
                tItem.GoodsPlan       = dataGridView1.Rows[i].Cells["GoodsPlan"].Value.ToString();
                tItem.GoodsPlanNo     = dataGridView1.Rows[i].Cells["GoodsPlanNo"].Value.ToString();

                tItems.Add(tItem);
            }

            BLL.RKBLL.AddRKD(tR, tItems);
            this.Close();
        }
Example #12
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        btnSave.Focus();
        var receipt = new Receipt();
        var lstSavingReceiptItem = new List <ReceiptItem>();

        if (!ReceiptItems.Any())
        {
            ShowError(Exception.UnselectedItem);
            return;
        }

        UpdateReceiptValue();

        if (IsLoaded)
        {
            receipt.CopyPropertiesFrom(Original_Receipt);
        }

        receipt.SubstitutionICMSBase  = ucCurrFieldSubstituionICMSBase.CurrencyValue;
        receipt.SubstitutionICMSValue = ucCurrFieldSubstituionICMSValue.CurrencyValue;
        receipt.FreightValue          = ucCurrFieldFreightValue.CurrencyValue;
        receipt.InsuranceValue        = ucCurrFieldInsuranceValue.CurrencyValue;
        receipt.OthersChargesValue    = ucCurrFieldOthersChargesValue.CurrencyValue;


        if (!String.IsNullOrEmpty(lblReceiptValue.Text))
        {
            receipt.ReceiptValue = Convert.ToDecimal(lblReceiptValue.Text.Replace("_", ""));
        }

        receipt.CompanyId = Company.CompanyId;

        if (Page.ViewState["customerId"] != null)
        {
            receipt.SupplierId = null;
            receipt.CustomerId = Convert.ToInt32(Page.ViewState["customerId"]);
        }
        else
        {
            receipt.CustomerId = null;
            receipt.SupplierId = Convert.ToInt32(Page.ViewState["SupplierId"]);
        }
        if (Page.ViewState["TransporterId"] != null)
        {
            receipt.TransporterId = Convert.ToInt32(Page.ViewState["TransporterId"]);
        }

        receipt.DeliveryDate = null;
        receipt.EntryDate    = null;

        if (ucEntrydate.DateTime.HasValue)
        {
            receipt.EntryDate = ucEntrydate.DateTime;
        }
        else
        {
            receipt.DeliveryDate = ucDeliveryDate.DateTime;
        }

        if (ucIssueDate.DateTime.HasValue)
        {
            receipt.IssueDate = ucIssueDate.DateTime.Value;
        }

        receipt.CfopId = Convert.ToInt32(cboCFOP.SelectedValue);

        receipt.ReceiptNumber = ucCurrFieldReceiptNumber.IntValue;

        foreach (ReceiptItem item in ReceiptItems)
        {
            item.ReceiptId = receipt.ReceiptId;
            lstSavingReceiptItem.Add(item);
        }

        try
        {
            ///update ReceiptValue
            ReceiptManager.SaveReceipt(Original_Receipt, receipt, lstSavingReceiptItem, LstServiceOrder, LstSale);
        }
        catch (InvalidOperationException)
        {
            ShowError(Exception.InvalidReceiptNumber);
            return;
        }
        Server.Transfer("Receipts.aspx");
    }
Example #13
0
    protected void btnReceipItemProduct_Click(object sender, ImageClickEventArgs e)
    {
        //
        // Popula o receiptItem
        //
        Inventory inventory;
        Decimal   icms = 0, ipi = 0;
        Product   product     = SelProductAndService.Product;
        Service   service     = SelProductAndService.Service;
        var       receiptItem = new ReceiptItem();

        if (ucCurrFieldIPI.CurrencyValue.HasValue)
        {
            ipi = ucCurrFieldIPI.CurrencyValue.Value;
        }

        if (ucCurrFieldICMS.CurrencyValue.HasValue)
        {
            icms = ucCurrFieldICMS.CurrencyValue.Value;
        }

        receiptItem.ICMS        = icms;
        receiptItem.IPI         = ipi;
        receiptItem.Description = SelProductAndService.Name;
        receiptItem.UnitPrice   = ucCurrFieldUnitPrice.CurrencyValue;

        if (ucCurrFieldProductQuantity.IntValue != 0)
        {
            receiptItem.Quantity = ucCurrFieldProductQuantity.IntValue;
        }
        else
        {
            ShowError("Quantidade não pode ser zero!");
            return;
        }

        if (product != null)
        {
            receiptItem.ProductId   = product.ProductId;
            receiptItem.Description = product.Name;
            if (!ucCurrFieldUnitPrice.CurrencyValue.HasValue)
            {
                inventory = InventoryManager.GetInventory(Company.CompanyId, product.ProductId, Deposit.DepositId);
                if (inventory != null)
                {
                    receiptItem.UnitPrice = inventory.UnitPrice;
                }
            }
        }
        else if (service != null)
        {
            receiptItem.ServiceId   = service.ServiceId;
            receiptItem.Description = service.Name;
            if (!ucCurrFieldUnitPrice.CurrencyValue.HasValue)
            {
                receiptItem.UnitPrice = service.Price;
            }
        }

        //
        // Adiciona na Lista que está em memória
        // OBS: Ainda não foi para o banco de dados
        //
        ReceiptItems.Add(receiptItem);

        CalculateTotal(GetReceiptItemTotalValue(receiptItem, 1));

        BindReceiptItems();

        //
        // Limpar os campos de produto
        //
        ucCurrFieldProductQuantity.Text = String.Empty;
        ucCurrFieldUnitPrice.Text       = String.Empty;
        ucCurrFieldIPI.Text             = String.Empty;
        ucCurrFieldICMS.Text            = String.Empty;
    }
Example #14
0
        public async Task Refresh()
        {
            // NEED TO REWORK FOR THE NEW VIEW - OUTDATED

            IsLoading = true;

            #region Receipts
            Receipts.Clear();
            List <AlbumItem> receipts = await _azure.GetAllImages(CurrentTransaction.ID, true);

            foreach (AlbumItem t in receipts)
            {
                Receipts.Add(t);
            }

            receipts.Add(new AlbumItem {
                IsAddButton = true, IsReceipt = true
            });
            int            i       = 0;
            ImageListItems tempILI = new ImageListItems();

            //ClearItems before applying new items
            ReceiptItems.Clear();
            foreach (AlbumItem t in receipts)
            {
                //RESET temp class for next ListEntry
                if (tempILI == null)
                {
                    tempILI = new ImageListItems();
                }

                //Add Image
                tempILI.ItemImages.Add(t);

                //Add ListEntry content and reset for next Entry
                if (i >= 3)
                {
                    ReceiptItems.Add(tempILI);
                    tempILI = null;
                    i       = 0;
                }
                i++;
            }

            //Fill aditional spaces with filler image
            if (tempILI != null)
            {
                for (int j = tempILI.ItemImages.Count; j < 3; j++)
                {
                    tempILI.ItemImages.Add(new AlbumItem());
                }
                ReceiptItems.Add(tempILI);
            }
            #endregion

            //Reset Values to refresh Goods
            tempILI = null;
            i       = 0;

            #region Goods
            Goods.Clear();
            List <AlbumItem> goods = await _azure.GetAllImages(CurrentTransaction.ID, false);

            foreach (AlbumItem t in goods)
            {
                Goods.Add(t);
            }

            goods.Add(new AlbumItem {
                IsAddButton = true, IsReceipt = false
            });
            //ClearItems before applying new items
            GoodsItems.Clear();
            foreach (AlbumItem t in goods)
            {
                if (tempILI == null)
                {
                    tempILI = new ImageListItems();
                }

                tempILI.ItemImages.Add(t);
                if (i >= 3)
                {
                    GoodsItems.Add(tempILI);
                    tempILI = null;
                    i       = 0;
                }
                i++;
            }

            //Fill aditional spaces with filler image
            if (tempILI != null)
            {
                for (int j = tempILI.ItemImages.Count; j < 3; j++)
                {
                    tempILI.ItemImages.Add(new AlbumItem());
                }
                GoodsItems.Add(tempILI);
            }
            #endregion

            List <AlbumItem> images = await _azure.GetAllImages(CurrentTransaction.ID);

            foreach (AlbumItem image in images)
            {
                Images.Add(image);
            }

            if (!IsUnitTesting)
            {
                HockeyApp.MetricsManager.TrackEvent("Images Page Loaded");
            }

            IsLoading = false;
        }