Example #1
0
 public void GetMaxAsset()
 {
     Client.GetMaxAssetsAsync();
     if (AssetsTypeList != null)
     {
         SelectedMainRow.AssetTypePerRow = AssetsTypeList.FirstOrDefault(x => x.Code == "N/A");
         if (SelectedMainRow.AssetTypePerRow != null)
         {
             SelectedMainRow.TblAssetsType = SelectedMainRow.AssetTypePerRow.Iserial;
         }
     }
     if (HardDiskList != null)
     {
         SelectedMainRow.HardDiskPerRow = HardDiskList.FirstOrDefault(x => x.Code == "N/A");
         if (SelectedMainRow.HardDiskPerRow != null)
         {
             SelectedMainRow.TblHardDisk = SelectedMainRow.HardDiskPerRow.Iserial;
         }
     }
     if (MemoryList != null)
     {
         SelectedMainRow.MemoryPerRow = MemoryList.FirstOrDefault(x => x.Code == "N/A");
         if (SelectedMainRow.MemoryPerRow != null)
         {
             SelectedMainRow.TblMemory = SelectedMainRow.MemoryPerRow.Iserial;
         }
     }
     if (ProcessorList != null)
     {
         SelectedMainRow.ProcessorPerRow = ProcessorList.FirstOrDefault(x => x.Code == "N/A");
         if (SelectedMainRow.ProcessorPerRow != null)
         {
             SelectedMainRow.TblProcessor = SelectedMainRow.ProcessorPerRow.Iserial;
         }
     }
 }
Example #2
0
        public void SaveMainRow()
        {
            if (SelectedMainRow != null)
            {
                var valiationCollection = new List <ValidationResult>();

                var isvalid = Validator.TryValidateObject(SelectedMainRow, new ValidationContext(SelectedMainRow, null, null), valiationCollection, true);

                if (isvalid)
                {
                    var save = SelectedMainRow.Iserial == 0;
                    if (save)
                    {
                        if (AllowAdd != true)
                        {
                            MessageBox.Show(strings.AllowAddMsg);
                            return;
                        }
                    }
                    else
                    {
                        if (AllowUpdate != true)
                        {
                            MessageBox.Show(strings.AllowUpdateMsg);
                            return;
                        }
                    }
                    var saveRow = new TblAsset();
                    if (AssetsTypeList != null && SelectedMainRow.TblAssetsType == null)
                    {
                        SelectedMainRow.AssetTypePerRow = AssetsTypeList.FirstOrDefault(x => x.Code == "N/A");
                        if (SelectedMainRow.AssetTypePerRow != null)
                        {
                            SelectedMainRow.TblAssetsType = SelectedMainRow.AssetTypePerRow.Iserial;
                        }
                    }
                    if (HardDiskList != null && SelectedMainRow.TblHardDisk == 0)
                    {
                        SelectedMainRow.HardDiskPerRow = HardDiskList.FirstOrDefault(x => x.Code == "N/A");
                        if (SelectedMainRow.HardDiskPerRow != null)
                        {
                            SelectedMainRow.TblHardDisk = SelectedMainRow.HardDiskPerRow.Iserial;
                        }
                    }
                    if (MemoryList != null && SelectedMainRow.TblMemory == 0)
                    {
                        SelectedMainRow.MemoryPerRow = MemoryList.FirstOrDefault(x => x.Code == "N/A");
                        if (SelectedMainRow.MemoryPerRow != null)
                        {
                            SelectedMainRow.TblMemory = SelectedMainRow.MemoryPerRow.Iserial;
                        }
                    }
                    if (ProcessorList != null && SelectedMainRow.TblProcessor == 0)
                    {
                        SelectedMainRow.ProcessorPerRow = ProcessorList.FirstOrDefault(x => x.Code == "N/A");
                        if (SelectedMainRow.ProcessorPerRow != null)
                        {
                            SelectedMainRow.TblProcessor = SelectedMainRow.ProcessorPerRow.Iserial;
                        }
                    }
                    saveRow.InjectFrom(SelectedMainRow);
                    Client.UpdateOrInsertTblAssetsAsync(saveRow, save, 0);
                }
                else
                {
                    MessageBox.Show("Data Was Not Saved");
                }
            }
        }