コード例 #1
0
 private void ProcessDetail(IList <string> entStrList, PurchaseInvoice piEnt)
 {
     if (entStrList != null && entStrList.Count > 0)
     {
         ArrayList idarray            = new ArrayList();
         string    purorderId         = string.Empty;
         decimal   totalInvoiceAmount = 0;
         for (int j = 0; j < entStrList.Count; j++)
         {
             Newtonsoft.Json.Linq.JObject objL   = JsonHelper.GetObject <Newtonsoft.Json.Linq.JObject>(entStrList[j]);
             PurchaseInvoiceDetail        pbdEnt = new PurchaseInvoiceDetail();
             pbdEnt.PurchaseInvoiceId     = piEnt.Id;
             pbdEnt.PurchaseOrderDetailId = objL.Value <string>("PurchaseOrderDetailId");
             pbdEnt.ProductId             = objL.Value <string>("ProductId");
             pbdEnt.ProductCode           = objL.Value <string>("ProductCode");
             pbdEnt.ProductName           = objL.Value <string>("ProductName");
             pbdEnt.BuyPrice        = Convert.ToDecimal(objL.Value <string>("BuyPrice"));
             pbdEnt.InvoiceQuantity = Convert.ToInt32(objL.Value <string>("InvoiceQuantity"));
             pbdEnt.InvoiceAmount   = Convert.ToDecimal(objL.Value <string>("InvoiceAmount"));
             pbdEnt.DoCreate();
             totalInvoiceAmount += pbdEnt.InvoiceAmount.Value;
             //循环每个采购详细的发票数量 如果==采购数  则状态改为已关联
             int novoice = Convert.ToInt32(DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_getNoInvoiceQuantityByPurchaseOrderDetailId('" + pbdEnt.PurchaseOrderDetailId + "')"));
             if (novoice == 0)
             {
                 PurchaseOrderDetail podEnt = PurchaseOrderDetail.TryFind(objL.Value <string>("PurchaseOrderDetailId"));
                 if (podEnt.PurchaseOrderId != purorderId)
                 {
                     idarray.Add(podEnt.PurchaseOrderId);
                     purorderId = podEnt.PurchaseOrderId;
                 }
                 podEnt.InvoiceState = "已关联";
                 podEnt.DoUpdate();
             }
         }
         //如果所有发票详细的金额==发票的总金额  则把发票的状态改为已关联
         if (totalInvoiceAmount == piEnt.InvoiceAmount)
         {
             piEnt.State = "已关联";
             piEnt.DoUpdate();
         }
         //遍历采购单 如果其下所有的采购详细的发票状态都是已关联 则自身变为已关联
         for (int k = 0; k < idarray.Count; k++)
         {
             IList <EasyDictionary> edics = DataHelper.QueryDictList("select Id from SHHG_AimExamine..PurchaseOrderDetail where PurchaseOrderId='" + idarray[k].ToString() + "' and  InvoiceState='未关联'");
             if (edics.Count == 0)
             {
                 PurchaseOrder poEnt = PurchaseOrder.TryFind(idarray[k].ToString());
                 poEnt.InvoiceState = "已关联";
                 if (poEnt.InWarehouseState == "已入库" && poEnt.PayState == "已付款")
                 {
                     poEnt.OrderState = "已结束";
                 }
                 poEnt.DoUpdate();
             }
         }
     }
 }
コード例 #2
0
        private void UpdatePayState(string payBillId)
        {
            string tempsql = @"select * from SHHG_AimExamine..PayBillDetail where PayBillId='{0}'";

            tempsql = string.Format(tempsql, payBillId);
            IList <EasyDictionary> dicPayDetail = DataHelper.QueryDictList(tempsql);
            PurchaseOrderDetail    podEnt       = null;
            ArrayList idarray = new ArrayList();//搜集涉及的采购单ID
            string    poId    = string.Empty;
            string    podId   = string.Empty;
            int       nopay   = 0;

            foreach (EasyDictionary ea in dicPayDetail)
            {
                podId  = ea.Get <string>("PurchaseOrderDetailId");
                podEnt = PurchaseOrderDetail.TryFind(podId);
                //取得采购详细的实际未付款数目
                nopay = Convert.ToInt32(DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_ActuallNoPayQuan('" + podId + "')"));
                if (nopay == 0)
                {
                    podEnt.PayState = "已付款";
                    podEnt.DoUpdate();
                }
                if (podEnt.PurchaseOrderId != poId)
                {
                    poId = podEnt.PurchaseOrderId;
                    idarray.Add(poId);
                }
            }
            //付款单涉及的采购详细表状态遍历完后。再遍历付款单涉及的采购单
            PurchaseOrder poEnt = null;

            foreach (object ob in idarray)
            {
                IList <PurchaseOrderDetail> podEnts = PurchaseOrderDetail.FindAll("from PurchaseOrderDetail where PayState='未付款' and PurchaseOrderId='" + ob.ToString() + "'");
                if (podEnts.Count == 0)
                {
                    poEnt          = PurchaseOrder.TryFind(ob.ToString());
                    poEnt.PayState = "已付款";
                    if (poEnt.InvoiceState == "已关联" && poEnt.InWarehouseState == "已入库")
                    {
                        poEnt.OrderState = "已结束";
                    }
                    poEnt.DoUpdate();
                }
            }
        }
コード例 #3
0
        private void DeleteInvoiceDetail(ArrayList idarray)
        {
            //原理基本同上。只不过一个传过来的是采购发票 而这个传递过来的时发票详细的id集合
            IList <PurchaseInvoiceDetail> pidEnts = new List <PurchaseInvoiceDetail>();

            for (int t = 0; t < idarray.Count; t++)
            {
                PurchaseInvoiceDetail tempEnt = PurchaseInvoiceDetail.TryFind(idarray[t].ToString());
                pidEnts.Add(tempEnt);
            }
            ArrayList           poidarray = new ArrayList();
            string              poid      = string.Empty;
            PurchaseOrderDetail podEnt    = null;

            for (int i = 0; i < pidEnts.Count; i++)
            {
                podEnt = PurchaseOrderDetail.TryFind(pidEnts[i].PurchaseOrderDetailId);//找发票详细对应的采购详细
                if (podEnt.PurchaseOrderId != poid)
                {
                    poid = podEnt.PurchaseOrderId;
                    poidarray.Add(poid);
                }
                if (podEnt.InvoiceState == "已关联")//如果采购详细的发票的状态已经改变了 则还原
                {
                    podEnt.InvoiceState = "未关联";
                    podEnt.DoUpdate();
                }
                pidEnts[i].Delete();//删除该发票详细
            }
            //再对采购详细涉及的采购单遍历一次  如果发票状态已改变 则还原
            for (int k = 0; k < poidarray.Count; k++)
            {
                PurchaseOrder poEnt = PurchaseOrder.TryFind(poidarray[k].ToString());
                IList <PurchaseOrderDetail> podEnts = PurchaseOrderDetail.FindAll("from PurchaseOrderDetail where PurchaseOrderId='" + poidarray[k].ToString() + "' and InvoiceState='未关联'");
                if (podEnts.Count > 0 && poEnt.InvoiceState == "已关联")
                {
                    poEnt.InvoiceState = "未关联";
                    poEnt.OrderState   = "未结束";
                    poEnt.DoUpdate();
                }
            }
            //至此采购订单和采购订单详细的状态回滚完毕
        }
コード例 #4
0
        private void DeleteInvoiceDetail(PurchaseInvoice piEnt)
        {
            //1 找到该发票下 所有的采购发票详细
            IList <PurchaseInvoiceDetail> pidEnts = PurchaseInvoiceDetail.FindAll("from PurchaseInvoiceDetail where PurchaseInvoiceId='" + piEnt.Id + "'");
            ArrayList           poidarray         = new ArrayList();
            string              poid   = string.Empty;
            PurchaseOrderDetail podEnt = null;

            for (int i = 0; i < pidEnts.Count; i++)
            {
                podEnt = PurchaseOrderDetail.TryFind(pidEnts[i].PurchaseOrderDetailId);//找发票详细对应的采购详细
                if (podEnt.PurchaseOrderId != poid)
                {
                    poid = podEnt.PurchaseOrderId;
                    poidarray.Add(poid);
                }
                if (podEnt.InvoiceState == "已关联")//如果采购详细的发票的状态已经改变了 则还原
                {
                    podEnt.InvoiceState = "未关联";
                    podEnt.DoUpdate();
                }
                pidEnts[i].Delete();//删除该发票详细
            }
            //再对采购详细涉及的采购单遍历一次  如果发票状态已改变 则还原
            for (int k = 0; k < poidarray.Count; k++)
            {
                PurchaseOrder poEnt = PurchaseOrder.TryFind(poidarray[k].ToString());
                IList <PurchaseOrderDetail> podEnts = PurchaseOrderDetail.FindAll("from PurchaseOrderDetail where PurchaseOrderId='" + poidarray[k].ToString() + "' and InvoiceState='未关联'");
                if (podEnts.Count > 0 && poEnt.InvoiceState == "已关联")
                {
                    poEnt.InvoiceState = "未关联";
                    poEnt.OrderState   = "未结束";
                    poEnt.DoUpdate();
                }
            }
            //至此订单和订单详细的状态回滚完毕
        }
コード例 #5
0
        string type = String.Empty; // 对象类型
        protected void Page_Load(object sender, EventArgs e)
        {
            op   = RequestData.Get <string>("op");
            id   = RequestData.Get <string>("id");
            type = RequestData.Get <string>("type");
            PayBill ent = null;

            switch (RequestActionString)
            {
            case "PayBillPay":
                ent = PayBill.Find(id);
                ActualPayDetail apdEnt = new ActualPayDetail();
                if (!string.IsNullOrEmpty(RequestData.Get <string>("PayAmount")))
                {
                    ent.ActuallyPayAmount  = ent.ActuallyPayAmount + RequestData.Get <decimal>("PayAmount");
                    apdEnt.ActualPayAmount = RequestData.Get <decimal>("PayAmount");
                }
                apdEnt.PayBillId  = ent.Id;
                apdEnt.CreateId   = UserInfo.UserID;
                apdEnt.CreateName = UserInfo.Name;
                apdEnt.CreateTime = System.DateTime.Now;
                apdEnt.Remark     = RequestData.Get <string>("Remark");
                ent.DoUpdate();
                apdEnt.DoCreate();
                IList <PayBillDetail> pbdEnts = PayBillDetail.FindAll("from PayBillDetail where PayBillId='" + ent.Id + "'");
                Supplier supplierEnt          = Supplier.Find(ent.SupplierId);
                if (supplierEnt.Symbo == "¥")    //如果付款单的币种为本币
                {
                    if (ent.PAmount == ent.ActuallyPayAmount + (ent.DiscountAmount.HasValue ? ent.DiscountAmount.Value : 0))
                    {
                        ent.State = "已付款"; ent.DoUpdate();
                    }
                }
                //付款成功后 如果付款单为已付款状态 遍历采购单详细
                if (ent.State == "已付款")
                {
                    string tempsql = @"select * from SHHG_AimExamine..PayBillDetail where PayBillId='{0}'";
                    tempsql = string.Format(tempsql, ent.Id);
                    IList <EasyDictionary> dicPayDetail = DataHelper.QueryDictList(tempsql);
                    PurchaseOrderDetail    podEnt       = null;
                    ArrayList idarray = new ArrayList();    //搜集涉及的采购单ID
                    string    poId    = string.Empty;
                    string    podId   = string.Empty;
                    int       nopay   = 0;
                    foreach (EasyDictionary ea in dicPayDetail)
                    {
                        podId  = ea.Get <string>("PurchaseOrderDetailId");
                        podEnt = PurchaseOrderDetail.TryFind(podId);
                        //取得采购详细的实际未付款数目
                        nopay = Convert.ToInt32(DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_ActuallNoPayQuan('" + podId + "')"));
                        if (nopay == 0)
                        {
                            podEnt.PayState = "已付款";
                            podEnt.DoUpdate();
                        }
                        if (podEnt.PurchaseOrderId != poId)
                        {
                            poId = podEnt.PurchaseOrderId;
                            idarray.Add(poId);
                        }
                    }
                    //付款单涉及的采购详细表状态遍历完后。再遍历付款单涉及的采购单
                    PurchaseOrder poEnt = null;
                    foreach (object ob in idarray)
                    {
                        IList <PurchaseOrderDetail> podEnts = PurchaseOrderDetail.FindAll("from PurchaseOrderDetail where PayState='未付款' and PurchaseOrderId='" + ob.ToString() + "'");
                        if (podEnts.Count == 0)
                        {
                            poEnt          = PurchaseOrder.TryFind(ob.ToString());
                            poEnt.PayState = "已付款";
                            if (poEnt.InvoiceState == "已关联" && poEnt.InWarehouseState == "已入库")
                            {
                                poEnt.OrderState = "已结束";
                            }
                            poEnt.DoUpdate();
                        }
                    }
                }
                break;

            default:
                DoSelect();
                break;
            }
            if (op != "c" && op != "cs")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    string tempsql = @"select A.* ,B.MoneyType,B.Symbo from SHHG_AimExamine..PayBill as A 
                    left join SHHG_AimExamine..Supplier as B on A.SupplierId=B.Id where A.Id='{0}'";
                    tempsql = string.Format(tempsql, id);
                    IList <EasyDictionary> dics = DataHelper.QueryDictList(tempsql);
                    if (dics.Count > 0)
                    {
                        this.SetFormData(dics[0]);
                    }
                }
            }
        }