当前位置: 首页>>代码示例>>C#>>正文


C# UnitOfWork.FindObject方法代码示例

本文整理汇总了C#中UnitOfWork.FindObject方法的典型用法代码示例。如果您正苦于以下问题:C# UnitOfWork.FindObject方法的具体用法?C# UnitOfWork.FindObject怎么用?C# UnitOfWork.FindObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnitOfWork的用法示例。


在下文中一共展示了UnitOfWork.FindObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnConfirm_Click

        private void btnConfirm_Click(object sender, EventArgs e)
        {
            UnitOfWork uow;
            SubPurchOrderLine subPoLine;

            if (poLine.NeedQty != float.Parse(txtOKQty.Text) + float.Parse(txtDefectQty.Text))
            {
                XtraMessageBox.Show("良品数 + 来料不良数 需要等于要求数量");
                txtOKQty.Focus();
                return;
            }

            if (float.Parse(txtDefectQty.Text) < 0 || float.Parse(txtOKQty.Text) < 0)
            {
                XtraMessageBox.Show("良品数 或 来料不良数 不能少于零");
                txtOKQty.Focus();
                return;
            }

            uow = new UnitOfWork();
            uow.BeginTransaction();
            subPoLine = uow.FindObject<SubPurchOrderLine>(new BinaryOperator("Oid", poLine.Oid));
            subPoLine.OrderStatus = SubPurchOrderLine.PurchOrderStatus.Active;
            subPoLine.Save();

            // 若有来料不良, 即建立一个假生产单
            if (float.Parse(txtDefectQty.Text) > 0)
            {
                CreateProdOrderEntry(uow);
            }

            uow.CommitChanges();
            this.Close();
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:34,代码来源:frmSubConfirmIQC.cs

示例2: Update

        public override void Update() {
            var unitOfWork = new UnitOfWork(Session.DataLayer);

            if (unitOfWork.FindObject<PersistentAssemblyInfo>(null) != null)
                return;
            var persistentAssemblyInfo = new PersistentAssemblyInfo(unitOfWork){Name = "TestAssembly"};
            var persistentClassInfo = new PersistentClassInfo(unitOfWork){
                PersistentAssemblyInfo = persistentAssemblyInfo
            };
            persistentAssemblyInfo.PersistentClassInfos.Add(persistentClassInfo);
            persistentClassInfo.SetDefaultTemplate(TemplateType.Class);
            persistentClassInfo.Name = "TestClassInfo";
            persistentClassInfo.BaseType = typeof (Customer);
            persistentClassInfo.MergedObjectType = typeof (Customer);
            persistentClassInfo.TypeAttributes.Add(new PersistentDefaultClassOptionsAttribute(unitOfWork));
            persistentClassInfo.TypeAttributes.Add(new PersistentMapInheritanceAttribute(unitOfWork){
                MapInheritanceType = MapInheritanceType.ParentTable
            });
            var persistentCoreTypeMemberInfo = new PersistentCoreTypeMemberInfo(unitOfWork){
                DataType = DBColumnType.String,
                Name = "TestProp"
            };
            persistentClassInfo.OwnMembers.Add(persistentCoreTypeMemberInfo);
            persistentCoreTypeMemberInfo.SetDefaultTemplate(TemplateType.ReadWriteMember);
            

            unitOfWork.CommitChanges();
        }
开发者ID:kamchung322,项目名称:eXpand,代码行数:28,代码来源:DynamicMergingUpdater.cs

示例3: btnLoad_Click

        private void btnLoad_Click(object sender, EventArgs e)
        {
            mpPurchOrder = new mpPurchOrder();

            uow = new UnitOfWork();
            mpPurchOrder.WorkOrder = uow.FindObject<WorkOrder>(new BinaryOperator("Oid", lueStartWO.EditValue.ToString()));
            mpPurchOrder.StoreWH = uow.FindObject<WareHouse>(new BinaryOperator("Oid", lueWarehouse.EditValue.ToString()));
            mpPurchOrder.LeadTime = int.Parse(txtLeadTime.Text);

            XPCollection<WareHouse> wareHouses = new XPCollection<WareHouse>(uow);
            lueWarehouse2.DataSource = wareHouses;
            lueWarehouse2.ValueMember = "This";
            lueWarehouse2.DisplayMember = "WarehouseName";

            XPCollection<Vendor> vendors = new XPCollection<Vendor>(uow);
            lueVendor2.DataSource = vendors;
            lueVendor2.ValueMember = "This";
            lueVendor2.DisplayMember = "No";

            woPurchOrders = mpPurchOrder.CalcWoPurchOrder(uow);
            gridPurchOrderLine.DataSource = woPurchOrders;
            btnPost.Enabled = true;
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:23,代码来源:frmMpPurchOrder.cs

示例4: GetReport

        public static XafReport GetReport(string reportId)
        {
            using (UnitOfWork uow = new UnitOfWork())
            {
                XPObjectSpace objectSpace = new XPObjectSpace(uow, XafTypesInfo.Instance);
                CustomReportData reportData = uow.FindObject<CustomReportData>(new BinaryOperator("ReportId", reportId));

                if (reportData == null)
                    return null;

                XafReport xafReport = (XafReport)reportData.LoadReport(objectSpace);
                return xafReport;
            }
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:14,代码来源:ReportHelper.cs

示例5: CreateProdOrderEntry

        private void CreateProdOrderEntry(UnitOfWork uow)
        {
            SubProdOrder prodOrder = new SubProdOrder(uow);
            SubItem subItem = uow.FindObject<SubItem>(new BinaryOperator("Oid", poLine.SubItem.Oid));

            prodOrder.ProdOrderType = poLine.PurchOrderLineType;
            prodOrder.SubItem = subItem;
            prodOrder.Qty = float.Parse(txtDefectQty.Text);
            prodOrder.OrderStatus = SubProdOrder.ProdOrderStatus.Active;
            prodOrder.Save();

            SubProdOrderReceive prodOrderReceive = new SubProdOrderReceive(uow);
            prodOrderReceive.SubProdOrder = prodOrder;
            prodOrderReceive.DefectQty = prodOrder.Qty;
            prodOrderReceive.Save();
            prodOrderReceive.Post();
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:17,代码来源:frmSubConfirmIQC.cs

示例6: btnLoadNewPlanning_Click

        private void btnLoadNewPlanning_Click(object sender, EventArgs e)
        {
            uow = new UnitOfWork();

            XPCollection<OrderType> orderTypes = new XPCollection<OrderType>(uow);

            lueOrderType.DataSource = orderTypes;
            lueOrderType.ValueMember = "This";
            lueOrderType.DisplayMember = "Name";

            mpNewPlanning = mpNewPlanningReport.GetInstance(uow);
            mpNewPlanning.PostByPO = chkPostByPo.Checked;
            mpNewPlanning.Warehouse = uow.FindObject<WareHouse>(new BinaryOperator("Oid", lueWarehouse.EditValue));
            mpNewPlanning.GetWoPoTotal(uow);

            gridSchedule.DataSource = mpNewPlanning.woPoTotals;
            gridWO.DataSource = mpNewPlanning.woIssues;
            btnPostWO.Enabled = true;
            lblStatus.Text = string.Format("最后更新日期 : {0}", DateTime.Now);
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:20,代码来源:frmNewPlanningReport.cs

示例7: DoWalk

        private void DoWalk()
        {
            try
            {
                using (var uow = new UnitOfWork())
                {
                    var filesToBeAdded = new List<string>();
                    foreach (var m4VFile in Directory.EnumerateFiles(
                        _directoryToWalk, "*.m4v", SearchOption.AllDirectories))
                    {
                        var c = DevExpress.Data.Filtering.CriteriaOperator.Parse("Path = ?", m4VFile);
                        var v = uow.FindObject(typeof(Video), c);
                        if (v == null)
                        {
                            filesToBeAdded.Add(m4VFile);
                        }
                    }

                    foreach (var newFilePath in filesToBeAdded)
                    {
                        int cameraId;
                        DateTime time;
                        if (Util.TryParsePath(newFilePath, out cameraId, out time))
                        {
                            var nv = new Video(uow);
                            nv.Path = newFilePath;
                            nv.CaptureTime = time;
                            nv.CameraId = cameraId;
                            nv.Save();
                        }
                    }
                    uow.CommitChanges();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
开发者ID:dalinhuang,项目名称:appcollection,代码行数:39,代码来源:VideoFileWalker.cs

示例8: FindStudentID

        public string FindStudentID(string userName)
        {
            string result = "OK";
            try
            {
                using (UnitOfWork session = new UnitOfWork(XpoDefault.DataLayer))
                {

                    Student s = session.FindObject<Student>(new BinaryOperator("StudentCode",userName));

                    if (s!=null)
                        result = s.Oid.ToString();
                    else
                    {
                        result = "No student found!!!";
                    }
                }
            }
            catch
            {
                result = "Error";
            }
            return result;
        }
开发者ID:dedangkyphanmem,项目名称:vidodkmh,代码行数:24,代码来源:VidoWebService.asmx.cs

示例9: btnDeductFromWarehouse_Click

        private void btnDeductFromWarehouse_Click(object sender, EventArgs e)
        {
            UnitOfWork uow = new UnitOfWork();
            uow.BeginTransaction();

            foreach (int row in gridView1.GetSelectedRows())
            {
                PurchOrderLine poLine = (PurchOrderLine)gridView1.GetRow(row);

                if (poLine.OrderStatus != PurchOrderLine.PurchOrderStatus.Complete)
                {
                    XtraMessageBox.Show(string.Format("退货单 {0} 不能扣数 !!", poLine.PurchOrderNo));
                }
                else
                {
                    DialogResult dialResult = XtraMessageBox.Show(string.Format("请问是否扣以下退货数{0}\n注意 : 你需要在采购入仓确认内过帐. ", poLine.PurchOrderNo), "确认扣数", MessageBoxButtons.YesNo);

                    if (dialResult == DialogResult.Yes)
                    {
                        PurchOrderReceive pOrderReceive = new PurchOrderReceive(uow);
                        PurchOrderLine poLine2 = uow.FindObject<PurchOrderLine>(CriteriaOperator.Parse(string.Format("Oid = '{0}'", poLine.Oid)));
                        pOrderReceive.PurchOrderLine = poLine2;
                        pOrderReceive.Qty = poLine2.NeedQty * -1;
                        pOrderReceive.Remark = "";
                        pOrderReceive.Warehouse = poLine2.Warehouse;
                        pOrderReceive.VendorDN = "";
                        pOrderReceive.FreeSpareQty = 0;
                        pOrderReceive.Save();
                        pOrderReceive.Post();
                    }
                }
            }

            uow.CommitTransaction();
            initGrid();
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:36,代码来源:frmPurchOrderReturn.cs

示例10: Login

        public string Login(string userName, string passWord)
        {
            string result = "OK";
            try
            {
                using (UnitOfWork session = new UnitOfWork(XpoDefault.DataLayer))
                {

                    User s = session.FindObject<User>(new BinaryOperator("UserName", userName));

                    if (s != null && s.ComparePassword(passWord))
                        result = string.Format("{0}({1})",s.FullName,s.Oid);
                    else
                    {
                        result = "No user found!!!";
                    }
                }
            }
            catch
            {
                result = "Error";
            }
            return result;
        }
开发者ID:dedangkyphanmem,项目名称:vidodkmh,代码行数:24,代码来源:VidoWebService.asmx.cs

示例11: GetObject

 XPBaseObject GetObject(UnitOfWork unitOfWork, ITypeInfo typeInfo, CriteriaOperator criteriaOperator) {
     var xpBaseObject = unitOfWork.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, unitOfWork.GetClassInfo(typeInfo.Type),
                                              criteriaOperator,true) as XPBaseObject ??
                        unitOfWork.FindObject(unitOfWork.GetClassInfo(typeInfo.Type), criteriaOperator,true) as XPBaseObject;
     return xpBaseObject ?? (XPBaseObject)ReflectionHelper.CreateObject(typeInfo.Type, unitOfWork);
 }
开发者ID:gvilas,项目名称:eXpand,代码行数:6,代码来源:ImportEngine.cs

示例12: UpdateSOQty

 public static void UpdateSOQty(SubSalesOrderLine SubSOLine)
 {
     UnitOfWork uow = new UnitOfWork();
     uow.BeginTransaction();
     SubSalesOrderLine soLine = uow.FindObject<SubSalesOrderLine>(new BinaryOperator("Oid", SubSOLine.Oid));
     soLine.UpdateQty();
     soLine.Save();
     uow.CommitTransaction();
 }
开发者ID:kamchung322,项目名称:Namwah,代码行数:9,代码来源:SubSalesOrderLine.cs

示例13: btnIssueOrder_Click

        private void btnIssueOrder_Click(object sender, EventArgs e)
        {
            if (validateData() == false)
                return;

            StringBuilder sbMsg = new StringBuilder();

            UnitOfWork uow = new UnitOfWork();
            Customer customer = uow.FindObject<Customer>(new BinaryOperator("No", lueCustomer.EditValue));
            string poNo;

            uow.BeginTransaction();

            if (customer.No != "S")
                poNo = customer.No + txtPoNo.Text;
            else
                poNo = txtPoNo.Text;

            SalesOrder so = SalesOrder.Create(poNo, customer, uow);

            uow.CommitChanges();

            if (chkIssueWO1.Checked)
            {
                createWO(lueItem1.EditValue.ToString(), lueOrderType1.EditValue.ToString(),
                    DateTime.Parse(datNeedDate1.EditValue.ToString()), int.Parse(txtNeedQty1.EditValue.ToString()),
                            so, chkIssueSO1.Checked, uow, sbMsg);
            }

            if (chkIssueWO2.Checked)
            {
                createWO(lueItem2.EditValue.ToString(), lueOrderType2.EditValue.ToString(),
                    DateTime.Parse(datNeedDate2.EditValue.ToString()), int.Parse(txtNeedQty2.EditValue.ToString()),
                            so, chkIssueSO2.Checked, uow, sbMsg);
            }

            if (chkIssueWO3.Checked)
            {
                createWO(lueItem3.EditValue.ToString(), lueOrderType3.EditValue.ToString(),
                    DateTime.Parse(datNeedDate3.EditValue.ToString()), int.Parse(txtNeedQty3.EditValue.ToString()),
                            so, chkIssueSO3.Checked, uow, sbMsg);
            }

            if (chkIssueWO4.Checked)
            {
                createWO(lueItem4.EditValue.ToString(), lueOrderType4.EditValue.ToString(),
                    DateTime.Parse(datNeedDate4.EditValue.ToString()), int.Parse(txtNeedQty4.EditValue.ToString()),
                            so, chkIssueSO4.Checked, uow, sbMsg);
            }

            if (chkIssueWO5.Checked)
            {
                createWO(lueItem5.EditValue.ToString(), lueOrderType5.EditValue.ToString(),
                    DateTime.Parse(datNeedDate5.EditValue.ToString()), int.Parse(txtNeedQty5.EditValue.ToString()),
                            so, chkIssueSO5.Checked, uow, sbMsg);
            }

            if (chkIssueWO6.Checked)
            {
                createWO(lueItem6.EditValue.ToString(), lueOrderType6.EditValue.ToString(),
                    DateTime.Parse(datNeedDate6.EditValue.ToString()), int.Parse(txtNeedQty6.EditValue.ToString()),
                            so, chkIssueSO6.Checked, uow, sbMsg);
            }

            if (chkIssueWO7.Checked)
            {
                createWO(lueItem7.EditValue.ToString(), lueOrderType7.EditValue.ToString(),
                    DateTime.Parse(datNeedDate7.EditValue.ToString()), int.Parse(txtNeedQty7.EditValue.ToString()),
                            so, chkIssueSO7.Checked, uow, sbMsg);
            }

            if (chkIssueWO8.Checked)
            {
                createWO(lueItem8.EditValue.ToString(), lueOrderType8.EditValue.ToString(),
                    DateTime.Parse(datNeedDate8.EditValue.ToString()), int.Parse(txtNeedQty8.EditValue.ToString()),
                            so, chkIssueSO8.Checked, uow, sbMsg);
            }

            if (chkIssueWO9.Checked)
            {
                createWO(lueItem9.EditValue.ToString(), lueOrderType9.EditValue.ToString(),
                    DateTime.Parse(datNeedDate9.EditValue.ToString()), int.Parse(txtNeedQty9.EditValue.ToString()),
                            so, chkIssueSO9.Checked, uow, sbMsg);
            }

            uow.CommitTransaction();
            uow = null;

            if (sbMsg.ToString() != "")
                XtraMessageBox.Show(sbMsg.ToString(), "错误");
            else
                XtraMessageBox.Show("已发单", "完成");
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:93,代码来源:frmMassIssueWorkOrder.cs

示例14: Test_ModifySome_ReferenceObject

        public void Test_ModifySome_ReferenceObject()
        {
            CriteriaOperator criteria = CriteriaOperator.Parse("1=0");

            using (UnitOfWork uow = new UnitOfWork(DefaultDataLayer))
            {
                var referenceObject = uow.FindObject<MyReferenceObject>(null);
                Assert.AreNotEqual(Guid.Empty, referenceObject);
                Guid referenceId = referenceObject.Id;
                int affectedRecords = uow.GetObjectCount<MySimpleObject>(MySimpleObject.Fields.ReferenceProperty.Id == referenceId);
                uow.Update<MySimpleObject>(() => new MySimpleObject(uow) { ReferenceProperty = referenceObject }, criteria);
                Assert.AreEqual(affectedRecords, uow.GetObjectCount<MySimpleObject>(MySimpleObject.Fields.ReferenceProperty.Id == referenceId));
            }
        }
开发者ID:ZeroSharp,项目名称:XpoBatch,代码行数:14,代码来源:Tests_Modify.cs

示例15: Test_ModifyAll_ReferenceObject

 public void Test_ModifyAll_ReferenceObject()
 {
     using (UnitOfWork uow = new UnitOfWork(DefaultDataLayer))
     {
         var referenceObject = uow.FindObject<MyReferenceObject>(null);
         Assert.AreNotEqual(Guid.Empty, referenceObject);
         Guid referenceId = referenceObject.Id;
         Assert.Less(uow.GetObjectCount<MySimpleObject>(MySimpleObject.Fields.ReferenceProperty.Id == referenceId), 1000);
         uow.Update<MySimpleObject>(() => new MySimpleObject(uow) { ReferenceProperty = referenceObject }, null);
         Assert.AreEqual(1000, uow.GetObjectCount<MySimpleObject>(MySimpleObject.Fields.ReferenceProperty.Id == referenceId));
     }
 }
开发者ID:ZeroSharp,项目名称:XpoBatch,代码行数:12,代码来源:Tests_Modify.cs


注:本文中的UnitOfWork.FindObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。