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


C# Item.Save方法代码示例

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


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

示例1: ManyToOneTest

 public void ManyToOneTest()
 {
     Item Temp = new Item();
     Temp.Name = "Parent";
     for (int x = 0; x < 5; ++x)
     {
         Item Child = new Item();
         Child.Name = "Child " + x.ToString();
         Child.Parent = Temp;
         Child.Value = EnumValue.Value3;
         Temp.Children.Add(Child);
     }
     Temp.Save();
     Item Parent = Item.Any(new EqualParameter<long>(Temp.ID, "ID_"));
     foreach (Item Child in Parent.Children)
         Assert.Equal(Parent, Child.Parent);
     Assert.Equal(5, Parent.Children.Count);
     Assert.Equal(null, Parent.Parent);
     Parent.Children = Parent.Children.Remove(x => x.Name == "Child 0").ToList();
     Parent.Save();
     Parent = Item.Any(new EqualParameter<long>(Temp.ID, "ID_"));
     foreach (Item Child in Parent.Children)
         Assert.Equal(Parent, Child.Parent);
     Assert.Equal(4, Parent.Children.Count);
     Assert.Equal(null, Parent.Parent);
     Assert.Equal(EnumValue.Value3, Parent.Children[0].Value);
     Assert.Equal(EnumValue.Value3, Parent.Children[1].Value);
     Assert.Equal(EnumValue.Value3, Parent.Children[2].Value);
     Assert.Equal(EnumValue.Value3, Parent.Children[3].Value);
     Parent.Delete();
     Parent = Item.Any(new EqualParameter<long>(Temp.ID, "ID_"));
     Assert.Null(Parent);
     Assert.Equal(1, Item.All().Count());
 }
开发者ID:rgshare,项目名称:Craig-s-Utility-Library,代码行数:34,代码来源:ORMTest1.cs

示例2: Create

 public ActionResult Create(Item item)
 {
     if (ModelState.IsValid)
     {
         item.Save();
         return RedirectToAction("Index");
     }
     return View(item);
 }
开发者ID:IDM3,项目名称:CharecterSheetTracker,代码行数:9,代码来源:ItemsController.cs

示例3: btnSetNewPrice_Click

        private void btnSetNewPrice_Click(object sender, EventArgs e)
        {
            bool validated = false;
            ReceiveDoc rd = new ReceiveDoc();

            validated = dxValidationProviderPrice.Validate();

            if (!validated)
            {
                XtraMessageBox.Show("Please fill in all required fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!isConfirmation)
            {
                if (XtraMessageBox.Show("Are u sure, you want to save the new price change?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    MyGeneration.dOOdads.TransactionMgr transactionMgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
                    transactionMgr.BeginTransaction();
                    try
                    {
                        rs.NewUnitCost = Convert.ToDouble(txtAverageCost.EditValue);
                        rs.Margin = Convert.ToDouble(txtMargin.EditValue);
                        rs.NewSellingPrice = Convert.ToDouble(txtSellingPrice.EditValue);
                        rs.NewPrice = rs.NewSellingPrice;
                        //rs.Remark = txtRemark.EditValue.ToString();
                        // set the item as  weighted average item
                        Item itm = new Item();
                        itm.LoadByPrimaryKey(rs.ItemID);
                        itm.IsFree = false;

                        itm.Save();

                        rd.SavePrice(rs, CurrentContext.UserId);

                        transactionMgr.CommitTransaction();
                        XtraMessageBox.Show("Price setting successful", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    }
                    catch (Exception ex)
                    {
                        transactionMgr.RollbackTransaction();
                        XtraMessageBox.Show("Price setting failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        throw ex;

                    }
                }
            }
            else
            {
                if (XtraMessageBox.Show("Are you sure you want to approve the new price change.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    rd.ConfirmMovingAverage(rs, CurrentContext.UserId);
                    XtraMessageBox.Show("Price setting successful", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            ResetForm();
        }
开发者ID:USAID-DELIVER-PROJECT,项目名称:ethiopia-hcmis-warehouse,代码行数:59,代码来源:PriceSettingsHubConfirmation.cs

示例4: DataPortal_Update

        protected override void DataPortal_Update()
        {
            bool cancel = false;
            OnUpdating(ref cancel);
            if (cancel) return;

            if(OriginalItemId != ItemId)
            {
                // Insert new child.
                Item item = new Item {ItemId = ItemId, ProductId = ProductId, Status = Status, Name = Name, Image = Image};
                                if(ListPrice.HasValue) item.ListPrice = ListPrice.Value;
                if(UnitCost.HasValue) item.UnitCost = UnitCost.Value;
                if(Supplier.HasValue) item.Supplier = Supplier.Value;
                item = item.Save();

                // Mark editable child lists as dirty. This code may need to be updated to one-to-one relationships.

                // Create a new connection.
                using (var connection = new SqlConnection(ADOHelper.ConnectionString))
                {
                    connection.Open();
                    FieldManager.UpdateChildren(this, connection);
                }

                // Delete the old.
                var criteria = new ItemCriteria {ItemId = OriginalItemId};
                
                DataPortal_Delete(criteria);

                // Mark the original as the new one.
                OriginalItemId = ItemId;

                OnUpdated();

                return;
            }

            const string commandText = "UPDATE [dbo].[Item] SET [ItemId] = @p_ItemId, [ProductId] = @p_ProductId, [ListPrice] = @p_ListPrice, [UnitCost] = @p_UnitCost, [Supplier] = @p_Supplier, [Status] = @p_Status, [Name] = @p_Name, [Image] = @p_Image WHERE [ItemId] = @p_OriginalItemId; SELECT [ItemId] FROM [dbo].[Item] WHERE [ItemId] = @p_OriginalItemId";
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using(var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddWithValue("@p_OriginalItemId", this.OriginalItemId);
                command.Parameters.AddWithValue("@p_ItemId", this.ItemId);
                command.Parameters.AddWithValue("@p_ProductId", this.ProductId);
                command.Parameters.AddWithValue("@p_ListPrice", ADOHelper.NullCheck(this.ListPrice));
                command.Parameters.AddWithValue("@p_UnitCost", ADOHelper.NullCheck(this.UnitCost));
                command.Parameters.AddWithValue("@p_Supplier", ADOHelper.NullCheck(this.Supplier));
                command.Parameters.AddWithValue("@p_Status", ADOHelper.NullCheck(this.Status));
                command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name));
                command.Parameters.AddWithValue("@p_Image", ADOHelper.NullCheck(this.Image));

                    //result: The number of rows changed, inserted, or deleted. -1 for select statements; 0 if no rows were affected, or the statement failed. 
                    int result = command.ExecuteNonQuery();
                    if (result == 0)
                        throw new DBConcurrencyException("The entity is out of date on the client. Please update the entity and try again. This could also be thrown if the sql statement failed to execute.");

                    LoadProperty(_originalItemIdProperty, this.ItemId);
                }

                FieldManager.UpdateChildren(this, connection);
            }

            OnUpdated();
        }
开发者ID:codesmithtools,项目名称:Framework-Samples,代码行数:66,代码来源:Item.DataAccess.cs

示例5: btnSave_Click

        private void btnSave_Click(object sender, EventArgs e)
        {
            ReceiveDoc rd = new ReceiveDoc();
            if (!confirmation)
            {
                rs.NewUnitCost = Convert.ToDouble(txtAverageCost.EditValue);
                rs.Margin = Convert.ToDouble(txtMargin.EditValue);
                rs.NewSellingPrice = Convert.ToDouble(txtSellingPrice.EditValue);
                rs.NewPrice = rs.NewSellingPrice;

                // set the item as  weighted average item
                Item itm = new Item();
                itm.LoadByPrimaryKey(ItemID);
                itm.IsFree = false;

                itm.Save();

                rd.SavePrice(rs, CurrentContext.UserId);

                //if (!StoreType.IsFreeStore(StoreID))
                //{
                //    //Change the cost
                //    rs.NewCost = rs.NewUnitCost;
                //    rd.SaveNewCost(rs, NewMainWindow.UserId);
                //}

                //-----------
                XtraMessageBox.Show("New Price setting has been saved.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                rd.ConfirmMovingAverage(rs, CurrentContext.UserId);

            }
            this.Close();
        }
开发者ID:USAID-DELIVER-PROJECT,项目名称:ethiopia-hcmis-warehouse,代码行数:36,代码来源:CostSheet.cs

示例6: SaveHubDetails

        private void SaveHubDetails()
        {
            if (isStorageTypeChanged)
            {

                isStorageTypeChanged = false;
                BLL.ItemPrefferedLocation ipl = new ItemPrefferedLocation();
                ipl.LoadByItemID(itemId);
                while (!ipl.EOF)
                {
                    ipl.MarkAsDeleted();
                    ipl.MoveNext();
                }
                ipl.Save();

            }

            Item itm = new Item();

            if (cmbStorageType.SelectedValue != null)
            {
                if (cmbStorageType.SelectedValue.ToString() == StorageType.BulkStore)
                {
                    // store the stacked storage settings
                    itm.LoadByPrimaryKey(itemId);
                    itm.IsStackStored = chkIsStackStored.Checked;
                    itm.Save();

                    if (lstPreferredPalletLocation.ItemCount > 0)
                    {
                        //Items itm = new Items();

                        // save near expiry trigger point

                        ItemPrefferedLocation ipr = new ItemPrefferedLocation();
                        DataView dv = (DataView)lstPreferredPalletLocation.DataSource;
                        foreach (DataRowView drv in dv)
                        {
                            ipr.SaveNewItemPreferredRack(itemId, Convert.ToInt32(drv["ID"]),false);
                        }

                    }
                    // store pickface settings
                    pf.Rewind();
                    PickFace pfc = new PickFace();
                    while (!pf.EOF)
                    {
                        pf.AcceptChanges();
                        if (!pf.IsColumnNull("PalletLocationID"))
                        {
                            pfc.SavePickFaceLocation(itemId, pf.PalletLocationID, pf.LogicalStore);
                        }
                        else
                        {

                            pfc.LoadPickFaceFor(itemId, pf.LogicalStore);
                            if (pfc.RowCount> 0 && (pfc.IsColumnNull("Balance") || pfc.Balance == 0))
                            {
                                pfc.ClearPickFaceFor(itemId, pfc.LogicalStore);
                            }
                            else
                            {
                                //TODO: show the error message for the user
                            }

                        }
                        pf.MoveNext();
                    }

                }
                else
                {
                    // Save the fixed locations
                    var ipr = new ItemPrefferedLocation();
                    DataView dv = (DataView)lstPreferredPalletLocation.DataSource;
                    if (dv != null)
                    {
                        foreach (DataRowView drv in dv)
                        {
                            ipr.SaveNewItemPreferredRack(itemId, Convert.ToInt32(drv["ID"]), true);
                        }
                    }
                }

                itm.LoadByPrimaryKey(itemId);
                itm.StorageTypeID = int.Parse(cmbStorageType.SelectedValue.ToString());
                itm.NearExpiryTrigger = Convert.ToDouble(numNearExpiryTrigger.Value);
                itm.Save();

            }
        }
开发者ID:USAID-DELIVER-PROJECT,项目名称:ethiopia-hcmis-warehouse,代码行数:91,代码来源:BasicItemSettings.cs

示例7: btnSave_Click

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!AccountTypeSelectionValid())
            {
                XtraMessageBox.Show("Please choose to which account types this item applies to.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                gridViewStoreItemMatrix.SetColumnError(gridColAcctType, "At least one account type needs to be selected");
                return;
            }
            Item itm = new Item();
            ItemSupplier itmSup = new ItemSupplier();
            if (itemId != 0)
                itm.LoadByPrimaryKey(itemId);
            else
            {
                itm.AddNew();
                ItemCategory prodCate = new ItemCategory();
                prodCate.AddNew();
                prodCate.ItemId = itm.ID;
                prodCate.SubCategoryID = Convert.ToInt32(categoryId);
                prodCate.Save();
            }
            if(radioGroupABC.EditValue != null){
                itm.ABC = Convert.ToInt32(radioGroupABC.EditValue);
            }

            if (radioGroupVEN.EditValue != null)
            {
                itm.VEN = Convert.ToInt32(radioGroupVEN.EditValue);
            }
            itm.IsInHospitalList = ckExculed.Checked;
            itm.ProcessInDecimal = chkProcessDecimal.Checked;
            itm.Save();

            if (itm.IsInHospitalList)
            {
                SaveHubDetails();
            }
            else
            {
                // clear out the prefered locations
                // clear out the pick face locations
                // make sure that this item could be made not in the list

            }

            itmSup.DeleteAllSupForItem(itm.ID);
            Supplier sup = new Supplier();
            for (int i = 0; i < lstSuppliers.CheckedItems.Count;i++ )
            {
                sup.GetSupplierByName(lstSuppliers.CheckedItems[i].ToString());
                itmSup.AddNew();
                itmSup.ItemID = itm.ID;
                itmSup.SupplierID = sup.ID;
                itmSup.Save();
            }

            ItemProgram progItm = new ItemProgram();
            progItm.DeleteAllProgramsForItem(itemId);
            BLL.Program prog = new BLL.Program();
            for (int i = 0; i < lstPrograms.CheckedItems.Count; i++)
            {
                prog.GetProgramByName(lstPrograms.CheckedItems[i].ToString());
                progItm.AddNew();
                progItm.ItemID = itm.ID;
                progItm.ProgramID = prog.ID;
                progItm.Save();
            }

                XtraMessageBox.Show("Item Detail is Saved Successfully!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
开发者ID:USAID-DELIVER-PROJECT,项目名称:ethiopia-hcmis-warehouse,代码行数:71,代码来源:BasicItemSettings.cs

示例8: PopulateItems

        private void PopulateItems()
        {
            Item itm = new Item();
            itm.GetItemByPrimaryKey(this._itemID);
            if (itm.IsColumnNull("StorageTypeID"))
            {
                itm.StorageTypeID = 1;
                itm.Save();
            }
            if (itm.StorageTypeID.ToString() == StorageType.BulkStore && !itm.IsColumnNull("IsStackStored") && itm.IsStackStored)
            {
                layoutStackedView.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            }
            else
                layoutStackedView.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;

            lblItemName.Text = itm.FullItemName;
            BLL.ItemManufacturer imfr = new BLL.ItemManufacturer();
            imfr.LoadManufacturersFor(this._itemID);
            lstManufacturers.DataSource = imfr.DefaultView;
            itemUnit.LoadAllForItem(_itemID);
            gridUnits.DataSource = itemUnit.DefaultView;
        }
开发者ID:USAID-DELIVER-PROJECT,项目名称:ethiopia-hcmis-warehouse,代码行数:23,代码来源:ItemManufacturer.cs


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