示例#1
0
        protected override void CloneBillActorData(Session session, Guid billId, ref Bill ret)
        {
            NAS.DAL.Invoice.SalesInvoice source =
                session.GetObjectByKey <NAS.DAL.Invoice.SalesInvoice>(billId);

            foreach (var sourceBillActor in source.BillActors)
            {
                BillActor billActor = new BillActor(session)
                {
                    BillActorTypeId = sourceBillActor.BillActorTypeId,
                    BillId          = ret,
                    OrganizationId  = sourceBillActor.OrganizationId,
                    PersonId        = sourceBillActor.PersonId
                };
                billActor.Save();
            }
        }
示例#2
0
        /////////////////////////////////////////////////

        public Guid insertEmptyPurchaseInvoice(Session session)
        {
            NAS.DAL.Invoice.PurchaseInvoice purchaseInvoice = new NAS.DAL.Invoice.PurchaseInvoice(session);

            purchaseInvoice.BillId           = Guid.NewGuid();
            purchaseInvoice.RowStatus        = -1;
            purchaseInvoice.PurchasingStatus = "PO";
            purchaseInvoice.Save();

            XPCollection <BillActorType> collectBillActorType = new XPCollection <BillActorType>(session);

            if (collectBillActorType.Count <= 0)
            {
                BillActorType billActorType = new BillActorType(session);

                billActorType.Description = "Người lập phiếu";
                billActorType.Name        = "CREATOR";
                billActorType.RowStatus   = Constant.ROWSTATUS_ACTIVE;

                billActorType.Save();

                billActorType = new BillActorType(session);

                billActorType.Description = "Người mua hàng";
                billActorType.Name        = "BUYER";
                billActorType.RowStatus   = Constant.ROWSTATUS_ACTIVE;

                billActorType.Save();

                billActorType             = new BillActorType(session);
                billActorType.Description = "Người bán hàng";
                billActorType.Name        = "SALES";
                billActorType.RowStatus   = Constant.ROWSTATUS_ACTIVE;

                billActorType.Save();

                billActorType             = new BillActorType(session);
                billActorType.Description = "Kế toán trưởng";
                billActorType.Name        = "CHIEFACCOUNTANT";
                billActorType.RowStatus   = Constant.ROWSTATUS_ACTIVE;

                billActorType.Save();

                billActorType             = new BillActorType(session);
                billActorType.Description = "Giám đốc";
                billActorType.Name        = "DIRECTOR";
                billActorType.RowStatus   = Constant.ROWSTATUS_ACTIVE;

                billActorType.Save();
            }

            collectBillActorType = new XPCollection <BillActorType>(session);
            foreach (BillActorType billActorType in collectBillActorType)
            {
                BillActor billActor = new BillActor(session);
                billActor.BillId          = purchaseInvoice;
                billActor.BillActorTypeId = billActorType;
                billActor.Save();
            }

            return(purchaseInvoice.BillId);
        }
示例#3
0
        protected void grdPurchase_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            string[] p = e.Parameters.Split('|');
            switch (p[0])
            {
            case "copy":
                Guid id = Guid.Parse(p[1].ToString());

                Bill bill = session.GetObjectByKey <Bill>(id);
                if (bill != null)
                {
                    ArtifactCodeRuleBO artifactCodeRuleBO = new ArtifactCodeRuleBO();

                    Bill billCopy = new Bill(session);

                    billCopy.BillId               = new Guid();
                    billCopy.Code                 = bill.Code + "_copy";
                    billCopy.RowStatus            = 1;
                    billCopy.TargetOrganizationId = bill.TargetOrganizationId;
                    billCopy.SourceOrganizationId = bill.SourceOrganizationId;

                    CriteriaOperator filter   = new BinaryOperator("Code", billCopy.Code, BinaryOperatorType.Equal);
                    Bill             billTest = session.FindObject <Bill>(filter);

                    if (billTest == null)
                    {
                        billCopy.Save();
                    }
                    else
                    {
                        grdPurchase.JSProperties.Add("cpCopyFailed", billCopy.Code);
                        return;
                    }

                    filter = new BinaryOperator("BillId", id, BinaryOperatorType.Equal);
                    XPCollection <BillActor> collectBillActor = new XPCollection <BillActor>(session, filter);

                    foreach (BillActor ba in collectBillActor)
                    {
                        BillActor billActor = new BillActor(session);
                        billActor.BillId = billCopy;

                        billActor.BillActorId     = Guid.NewGuid();
                        billActor.BillActorTypeId = ba.BillActorTypeId;
                        billActor.OrganizationId  = ba.OrganizationId;
                        billActor.PersonId        = ba.PersonId;

                        billActor.Save();
                    }

                    filter = new BinaryOperator("BillId", id, BinaryOperatorType.Equal);
                    XPCollection <BillItem> collectBillItem = new XPCollection <BillItem>(session, filter);

                    foreach (BillItem bi in collectBillItem)
                    {
                        BillItem billItem = new BillItem(session);
                        billItem.BillId                = billCopy;
                        billItem.RowStatus             = 1;
                        billItem.BillItemId            = bi.BillItemId;
                        billItem.LotId                 = bi.LotId;
                        billItem.Price                 = bi.Price;
                        billItem.PromotionInNumber     = bi.PromotionInNumber;
                        billItem.PromotionInPercentage = bi.PromotionInPercentage;
                        billItem.Quantity              = bi.Quantity;
                        billItem.TotalPrice            = bi.TotalPrice;

                        billItem.Save();

                        filter = new BinaryOperator("BillItemId", id, BinaryOperatorType.Equal);
                        XPCollection <BillItemTax> collectBillItemTax = new XPCollection <BillItemTax>(session, filter);

                        foreach (BillItemTax bit in collectBillItemTax)
                        {
                            BillItemTax billItemTax = new BillItemTax(session);
                            billItemTax.BillItemId      = billItem;
                            billItemTax.BillItemTaxId   = Guid.NewGuid();
                            billItemTax.ItemTaxId       = bit.ItemTaxId;
                            billItemTax.TaxInNumber     = bit.TaxInNumber;
                            billItemTax.TaxInPercentage = bit.TaxInPercentage;

                            billItemTax.Save();
                        }
                    }


                    grdPurchase.JSProperties.Add("cpRefresh", billCopy.Code);
                }

                break;

            default:
                break;
            }
        }