Exemple #1
0
        public IList <Repair> GetAllByStockUnit(StockUnit stockUnit)
        {
            using (ISession session = NHibernateHelper.OpenSession())
            {
                if (!stockUnit.IsNew)
                {
                    var result = session.CreateCriteria <Repair>()
                                 .CreateCriteria("Unit")
                                 .CreateCriteria("StockUnit")
                                 .Add(Restrictions.Eq("Id", stockUnit.Id))
                                 .List <Repair>();

                    foreach (var item in result)
                    {
                        NHibernateUtil.Initialize(item.Unit);
                        NHibernateUtil.Initialize(item.Unit.StockUnit.StockNumber);
                        NHibernateUtil.Initialize(item.User);
                    }

                    return(result);
                }

                return(new List <Repair>());
            }
        }
Exemple #2
0
 public void Put(string id, StockUnit entity)
 {
     if (ModelState.IsValid)
     {
         db.UpdateStockUnit(entity.GetPrivateEntity <StockUnit>());
     }
 }
Exemple #3
0
        public async Task <ActionResult <StockUnit> > PostStockUnit(StockUnit stockUnit)
        {
            _context.StockUnits.Add(stockUnit);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetStockUnit", new { id = stockUnit.StockUnitId }, stockUnit));
        }
Exemple #4
0
        public ReturnType RemoveStockUnit(string stockunitCode)
        {
            try
            {
                using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString()))
                {
                    /*List<StockUnit> list = alading.StockUnit.Where(p => p.StockUnitID == stockunitID).ToList();*/
                    List <StockUnit> list = alading.StockUnit.Where(p => p.StockUnitCode == stockunitCode).ToList();
                    if (list.Count == 0)
                    {
                        return(ReturnType.NotExisted);
                    }

                    else
                    {
                        StockUnit sy = list.First();
                        alading.DeleteObject(sy);
                        alading.SaveChanges();
                        return(ReturnType.Success);
                    }
                }
            }
            catch (SqlException sex)
            {
                return(ReturnType.ConnFailed);
            }
            catch (System.Exception ex)
            {
                return(ReturnType.OthersError);
            }
        }
Exemple #5
0
        public async Task <IActionResult> PutStockUnit(int id, StockUnit stockUnit)
        {
            if (id != stockUnit.StockUnitId)
            {
                return(BadRequest());
            }

            _context.Entry(stockUnit).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StockUnitExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #6
0
 public ReturnType AddStockUnitGroup(StockUnitGroup stockunitgroup, StockUnit unit)
 {
     System.Data.Common.DbTransaction tran = null;
     using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString()))
     {
         try
         {
             alading.Connection.Open();
             tran = alading.Connection.BeginTransaction();
             alading.AddToStockUnitGroup(stockunitgroup);
             alading.AddToStockUnit(unit);
             alading.SaveChanges();
             tran.Commit();
             return(ReturnType.Success);
         }
         catch (System.Exception ex)
         {
             if (tran != null)
             {
                 tran.Rollback();
             }
             return(ReturnType.SaveFailed);
         }
         finally
         {
             if (alading != null && alading.Connection.State != System.Data.ConnectionState.Closed)
             {
                 alading.Connection.Close();
             }
         }
     }
 }
Exemple #7
0
 public ReturnType AddStockUnit(StockUnit stockunit)
 {
     try
     {
         using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString()))
         {
             alading.AddToStockUnit(stockunit);
             if (alading.SaveChanges() == 1)
             {
                 return(ReturnType.Success);
             }
             else
             {
                 return(ReturnType.PropertyExisted);
             }
         }
     }
     catch (SqlException sex)
     {
         return(ReturnType.ConnFailed);
     }
     catch (Exception ex)
     {
         return(ReturnType.OthersError);
     }
 }
        public StockUnitViewModel(StockUnit arg)
        {
            _stockUnitRepository     = new StockUnitRepository();
            _stockUnitNoteRepository = new StockUnitNoteRepository();

            InitViewModel(!arg.IsNew ? _stockUnitRepository.GetById(arg.Id, true) : arg);
        }
Exemple #9
0
        private void FillDocument(StockUnit arg, string filePath)
        {
            using (var wordDocument = WordprocessingDocument.Open(filePath, true))
            {
                var doc          = wordDocument.MainDocumentPart.Document;
                var xmlConverter = new StockUnitXmlConverter();
                var stockUnitXml = xmlConverter.Convert(arg);

                var body      = doc.Body;
                var tableList = body.Descendants <Table>().ToList();
                foreach (var table in tableList)
                {
                    var nodesValue = TableSelectNodesText("TblStart", table);
                    var startRow   = FindRowByMergeFieldText("TblStart", table, true);
                    var endRow     = FindRowByMergeFieldText("TblEnd", table, true);
                    if (startRow != null && endRow != null)
                    {
                        var nodes = stockUnitXml.SelectNodes(nodesValue);
                        FillTable(table, startRow, nodes);
                    }
                }

                var fieldCodes = body.Descendants <FieldCode>();
                foreach (var fieldCode in fieldCodes)
                {
                }


                doc.Save();
            }
        }
        public StockUnitAddView(StockUnit arg)
        {
            InitializeComponent();
            ViewModel   = new StockUnitViewModel(arg);
            DataContext = ViewModel;
            SetActions();

            StockNumberTb.Focus();
        }
        private void DisplayCopyDialog(StockUnit stockUnit)
        {
            var dialog = new StockUnitAddView(stockUnit)
            {
                Owner = Window.GetWindow(this)
            };

            dialog.Closed += (s, e) => dialog.Owner.Focus();
            dialog.Show();
        }
Exemple #12
0
        public IList <StockUnitFile> GetByStockUnitId(StockUnit stockUnit)
        {
            using (ISession session = NHibernateHelper.OpenSession())
            {
                var result = session.CreateCriteria <StockUnitFile>()
                             .CreateCriteria("StockUnit")
                             .Add(Restrictions.Eq("Id", stockUnit.Id))
                             .List <StockUnitFile>();

                return(result);
            }
        }
Exemple #13
0
        public string Post(StockUnit entity)
        {
            if (ModelState.IsValid)
            {
                db.InsertStockUnit(entity);

                entity.PublicId = entity.GetPublicId();
                return(entity.GetPublicEntity <StockUnit>().PublicId);
            }

            return(string.Empty);
        }
Exemple #14
0
        public ReturnType UpdateStockUnit(StockUnit stockunit)
        {
            try
            {
                using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString()))
                {
                    /*StockUnit result = alading.StockUnit.Where(p => p.StockUnitID == stockunit.StockUnitID).FirstOrDefault();*/
                    StockUnit result = alading.StockUnit.Where(p => p.StockUnitCode == stockunit.StockUnitCode).FirstOrDefault();
                    if (result == null)
                    {
                        return(ReturnType.NotExisted);
                    }
                    #region   Using Attach() Function Update,Default USE;
                    alading.Attach(result);
                    alading.ApplyPropertyChanges("StockUnit", stockunit);
                    #endregion

                    #region    Using All Items Replace To Update ,Default UnUse

                    /*
                     *
                     *  result.StockUnitCode = stockunit.StockUnitCode;
                     *
                     *  result.StockUnitName = stockunit.StockUnitName;
                     *
                     *  result.IsBaseUnit = stockunit.IsBaseUnit;
                     *
                     *  result.StockUnitGroupCode = stockunit.StockUnitGroupCode;
                     *
                     *  result.Conversion = stockunit.Conversion;
                     *
                     *  result.StockUnitSource = stockunit.StockUnitSource;
                     *
                     */
                    #endregion
                    if (alading.SaveChanges() == 1)
                    {
                        return(ReturnType.Success);
                    }

                    return(ReturnType.OthersError);
                }
            }
            catch (SqlException sex)
            {
                return(ReturnType.ConnFailed);
            }
            catch (Exception ex)
            {
                return(ReturnType.OthersError);
            }
        }
        public XmlDocument Convert(StockUnit arg)
        {
            _stockUnit = _repository.GetById(arg.Id, true);

            var doc = new XmlDocument();

            doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", "yes"));

            var root = (XmlElement)doc.AppendChild(doc.CreateElement("StockUnit"));

            AppendStockUnitProperties(doc, root);
            AppendUnits(doc, root);
            AppendRepair(doc, root);
            AppendNotes(doc, root);

            return(doc);
        }
        private void InitViewModel(StockUnit stockUnit)
        {
            _itemsToDelete         = new List <Unit>();
            _addedFiles            = new List <string>();
            _deletedFiles          = new List <string>();
            _deletedStockUnitFiles = new List <StockUnitFile>();

            StockUnit = stockUnit;
            if (StockUnit.IsNew && StockUnit.UnitList == null)
            {
                StockUnit.UnitList = new List <Unit>();
            }

            InitLists();
            UnitList = new ObservableCollection <Unit>(StockUnit.UnitList);
            UnitList.CollectionChanged += UnitList_CollectionChanged;

            var documentRepository = new DocumentRepository();

            DocumnetsList = new ObservableCollection <Document>(documentRepository.GetByStockUnit(StockUnit));
            var repairRepository = new RepairRepository();

            RepairList = new ObservableCollection <Repair>(repairRepository.GetAllByStockUnit(StockUnit));
            var filesRepository = new StockUnitFileRepository();

            StockUnitFiles = new ObservableCollection <StockUnitFile>(filesRepository.GetByStockUnitId(StockUnit));

            StockUnitNoteList = !StockUnit.IsNew ?
                                new ObservableCollection <StockUnitNote>(_stockUnitNoteRepository.GetByStockUnitId(StockUnit))
                : new ObservableCollection <StockUnitNote>();

            var repository = new UnitRepository();

            ManufactureList = repository.GetManufactureList();
            ModelList       = repository.GetModelList();

            AddUnitCommand    = new RelayCommand(x => UnitList.Add(new Unit()));
            RemoveUnitCommand = new RelayCommand(x => RemoveMethod());
            ReportsCommand    = new RelayCommand(x => ReportsMethod());
            SaveCommand       = new RelayCommand(x => SaveMethod());
            CloseCommand      = new RelayCommand(x => CloseMethod());
            AddFileCommand    = new RelayCommand(x => AddFileMethod());
            RemoveFileCommand = new RelayCommand(x => RemoveFileMethod());
            OpenFileCommand   = new RelayCommand(x => OpenFileMethod());
            OpenFolderCommand = new RelayCommand(x => OpenFolderMethod());
        }
Exemple #17
0
        public ReturnType UpdateStockUnit(string stockunitCode, StockUnit stockunit)
        {
            try
            {
                using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString()))
                {
                    /*var result = alading.StockUnit.Where(p => p.StockUnitID == stockunitID).ToList();*/
                    var result = alading.StockUnit.Where(p => p.StockUnitCode == stockunitCode).ToList();
                    if (result.Count == 0)
                    {
                        return(ReturnType.NotExisted);
                    }

                    StockUnit ob = result.First();
                    //ob.StockUnitCode = stockunit.StockUnitCode;
                    ob.StockUnitName = stockunit.StockUnitName;
                    //ob.IsBaseUnit = stockunit.IsBaseUnit;
                    //ob.StockUnitGroupCode = stockunit.StockUnitGroupCode;
                    ob.Conversion = stockunit.Conversion;
                    //ob.StockUnitSource = stockunit.StockUnitSource;
                    ob.Remark = stockunit.Remark;

                    if (alading.SaveChanges() == 1)
                    {
                        return(ReturnType.Success);
                    }
                    else
                    {
                        return(ReturnType.OthersError);
                    }
                }
            }
            catch (SqlException sex)
            {
                return(ReturnType.ConnFailed);
            }
            catch (System.Exception ex)
            {
                return(ReturnType.OthersError);
            }
        }
Exemple #18
0
        private void FillDocument(StockUnit arg, string filePath)
        {
            using (var wordDocument = WordprocessingDocument.Open(filePath, true))
            {
                var doc = wordDocument.MainDocumentPart.Document;

                ExportStockUnitData(doc, arg);
                ExportUnitData(doc, arg.UnitList);

                var repair = _repairRepository.GetAllByStockUnit(arg);
                ExportRepairData(doc, repair);

                var notes = _noteRepository.GetByStockUnitId(arg);
                ExportNoteData(doc, notes);

                RemoveSdtElements(doc);
                RemoveRubbish(doc);

                doc.Save();
            }
        }
        public IList <Document> GetByStockUnit(StockUnit stockUnit)
        {
            using (ISession session = NHibernateHelper.OpenSession())
            {
                if (!stockUnit.IsNew)
                {
                    var result = session.CreateCriteria <Document>()
                                 .CreateCriteria("StockUnitList", "s")
                                 .Add(Restrictions.Eq("s.Id", stockUnit.Id))
                                 .List <Document>();

                    foreach (var item in result)
                    {
                        NHibernateUtil.Initialize(item.DocumentType);
                        NHibernateUtil.Initialize(item.Owner);
                    }

                    return(result);
                }

                return(new List <Document>());
            }
        }
Exemple #20
0
        private TableRow GetUnitTableRow(StockUnit stockUnit, Unit unit, int pointA, int pointB)
        {
            TableRow tr = new TableRow();

            TableCell cell1      = new TableCell();
            Paragraph paragraph1 = cell1.AppendChild(new Paragraph());
            Run       run1       = paragraph1.AppendChild(new Run());

            run1.AppendChild(new Text((pointA + 1) + "." + (pointB + 1)));

            TableCell cell2      = new TableCell();
            Paragraph paragraph2 = cell2.AppendChild(new Paragraph());
            Run       run2       = paragraph2.AppendChild(new Run());

            run2.AppendChild(new Text(unit.UnitType.TypeName));
            run2.AppendChild(new Break());
            run2.AppendChild(new Text(unit.Manufacture + " " + unit.ModelName));

            TableCell cell3      = new TableCell();
            Paragraph paragraph3 = cell3.AppendChild(new Paragraph());
            Run       run3       = paragraph3.AppendChild(new Run());

            run3.AppendChild(new Text(unit.Serial));
            run3.AppendChild(new Break());
            run3.AppendChild(new Text("(инв.№" + stockUnit.StockNumber + ")"));

            var       comments   = unit.Comments;
            TableCell cell4      = new TableCell();
            Paragraph paragraph4 = cell4.AppendChild(new Paragraph());
            Run       run4       = paragraph4.AppendChild(new Run());

            run4.AppendChild(new Text(comments));

            tr.Append(cell1, cell2, cell3, cell4);
            return(tr);
        }
Exemple #21
0
 public static ReturnType UpdateStockUnit(string stockunitCode, StockUnit stockunit)
 {
     return(DataProviderClass.Instance().UpdateStockUnit(stockunitCode, stockunit));
 }
Exemple #22
0
 public static ReturnType AddStockUnit(StockUnit stockunit)
 {
     return(DataProviderClass.Instance().AddStockUnit(stockunit));
 }
Exemple #23
0
        private void ExportStockUnitData(DocumentFormat.OpenXml.Wordprocessing.Document doc, StockUnit stockUnit)
        {
            string tag;

            tag = "StockUnit:StockNumber";
            FillRepeatingData(doc, tag, stockUnit.StockNumber, false);
            tag = "StockUnit:StockName";
            FillRepeatingData(doc, tag, stockUnit.StockName, false);
            tag = "StockUnit:CreationDate";
            FillRepeatingData(doc, tag, stockUnit.CreationDate.ToShortDateString(), false);
        }
Exemple #24
0
        //after Save For Grid Data
        public List <PRDChemProdReqItem> GetTransactionItemList(long _TransactionID, string _IssueFrom)
        {
            using (var context = new BLC_DEVEntities())
            {
                var StockResult = (from p in context.INV_ChemStockSupplier
                                   where p.StoreID.ToString() == _IssueFrom
                                   group p by new
                {
                    //p.StoreID,
                    p.SupplierID,
                    p.PackSize,
                    p.ItemID,
                    p.SizeUnit,
                    p.UnitID
                } into g
                                   select new
                {
                    TransectionID = g.Max(p => p.TransectionID),
                    //StoreID = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.StoreID).FirstOrDefault(),
                    ItemID = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.ItemID).FirstOrDefault(),
                    SupplierID = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.SupplierID).FirstOrDefault(),
                    //UnitID = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.UnitID).FirstOrDefault(),
                    PackSize = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.PackSize).FirstOrDefault(),
                    SizeUnit = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.SizeUnit).FirstOrDefault(),
                    PackQty = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.PackClosingQty).FirstOrDefault(),
                    ClosingQty = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.ClosingQty).FirstOrDefault(),
                    StockUnit = g.Where(p => p.TransectionID == g.Max(q => q.TransectionID)).Select(x => x.UnitID).FirstOrDefault()
                });

                var Data = (from i in context.INV_StoreTransItem
                            where i.TransactionID == _TransactionID

                            // Stock Size
                            from s in StockResult.Where(x => x.ItemID == i.ItemID && x.PackSize == i.PackSize && x.SizeUnit == i.SizeUnit && x.SupplierID == i.SupplierID).DefaultIfEmpty()


                            join si in context.Sys_Size on(s == null ? null : s.PackSize) equals si.SizeID into StockSize
                            from si in StockSize.DefaultIfEmpty()

                            join siu in context.Sys_Unit on(s == null ? null : s.SizeUnit) equals siu.UnitID into StockSizeUnit
                            from siu in StockSizeUnit.DefaultIfEmpty()

                            join su in context.Sys_Unit on(s == null ? null : s.StockUnit) equals su.UnitID into StockUnit
                            from su in StockUnit.DefaultIfEmpty()
                            // Stock Size


                            join it in context.Sys_ChemicalItem on(i == null ? null : i.ItemID) equals it.ItemID into Chemicals
                            from it in Chemicals.DefaultIfEmpty()

                            join sup in context.Sys_Supplier on(i == null ? null : i.SupplierID) equals sup.SupplierID into Suppliers
                            from sup in Suppliers.DefaultIfEmpty()

                            join iu in context.Sys_Unit on(i == null ? null : i.TransactionUnit) equals iu.UnitID into IUnits
                            from iu in IUnits.DefaultIfEmpty()

                            join issuesize in context.Sys_Size on(i == null ? null : i.PackSize) equals issuesize.SizeID into IssueSizes
                            from issuesize in IssueSizes.DefaultIfEmpty()

                            join issuesizeunit in context.Sys_Unit on(i == null ? null : i.SizeUnit) equals issuesizeunit.UnitID into IssueSizeUnit
                            from issuesizeunit in IssueSizeUnit.DefaultIfEmpty()

                            orderby(it == null ? null : it.ItemName)

                            select new PRDChemProdReqItem
                {
                    TransItemID = i.TransItemID,
                    ItemID = i.ItemID,
                    ItemName = (it == null ? null : it.ItemName),
                    SupplierID = i.SupplierID,
                    SupplierName = (sup == null ? null : sup.SupplierName),

                    PackSize = (s == null ? 0 : s.PackSize),
                    PackSizeName = (si == null ? null : si.SizeName),
                    SizeUnit = (s == null ? 0 : s.SizeUnit),
                    SizeUnitName = (siu == null ? null : siu.UnitName),
                    PackQty = (s == null ? 0 : (Int32)(s.PackQty)),

                    StockQty = (s == null ? 0 : s.ClosingQty),
                    StockUnit = (s == null ? 0 : s.StockUnit),
                    StockUnitName = (su == null ? null : su.UnitName),

                    IssuePackSize = i.PackSize,
                    IssuePackSizeName = (issuesize == null ? null : issuesize.SizeName),
                    IssueSizeUnit = i.SizeUnit,
                    IssueSizeUnitName = (issuesizeunit == null ? null : issuesizeunit.UnitName),
                    IssuePackQty = i.PackQty,
                    IssueQty = i.TransactionQty,
                    IssueUnitName = (iu == null ? null : iu.UnitName)
                }).ToList();
                return(Data);
            }
        }
 public static ReturnType AddStockUnitGroup(StockUnitGroup stockunitgroup, StockUnit unit)
 {
     return(DataProviderClass.Instance().AddStockUnitGroup(stockunitgroup, unit));
 }