Exemple #1
0
 private void UpdateLegalEntity(LegalEntity item, LegalEntity editedItem)
 {
     item.Name = editedItem.Name;
     item.Code = editedItem.Code;
     item.Phone = editedItem.Phone;
     item.Fax = editedItem.Fax;
     item.Email = editedItem.Email;
     item.IsVATPayer = editedItem.IsVATPayer;
     item.ActualAddress = editedItem.ActualAddress;
     item.Comment = editedItem.Comment;
     item.Director = editedItem.Director;
     item.ChiefAccountant = editedItem.ChiefAccountant;
 }
Exemple #2
0
        public ActionResult LegalEntityEditRows(LegalEntity editedItem)
        {
            // Get the grid and database models
            var gridModel = new SkladJqGridModel();
            var datacontextModel = new SkladDataContext();

            // If we are in "Edit" mode
            if (gridModel.LegalEntityGrid.AjaxCallBackMode == AjaxCallBackMode.EditRow)
            {
                // Get the data from and find the item corresponding to the edited row
                LegalEntity item = (from x in datacontextModel.LegalEntities
                                    where x.LegalEntityId == editedItem.LegalEntityId
                               select x).First<LegalEntity>();

                // update the Order information
                UpdateLegalEntity(item, editedItem);

                datacontextModel.SaveChanges();
            }

            if (gridModel.LegalEntityGrid.AjaxCallBackMode == AjaxCallBackMode.AddRow)
            {
                // since we are adding a new item, create a new istance
                LegalEntity item = new LegalEntity();
                // set the new item information
                UpdateLegalEntity(item, editedItem);

                datacontextModel.LegalEntities.Add(item);
                datacontextModel.SaveChanges();
            }
            if (gridModel.LegalEntityGrid.AjaxCallBackMode == AjaxCallBackMode.DeleteRow)
            {
                LegalEntity item = (from x in datacontextModel.LegalEntities
                                    where x.LegalEntityId == editedItem.LegalEntityId
                               select x)
                               .First<LegalEntity>();

                // delete the record
                datacontextModel.LegalEntities.Remove(item);
                datacontextModel.SaveChanges();
            }

            return RedirectToAction("LegalEntity", "MyCompany");
        }