Esempio n. 1
0
        public void Add(List <MRPDDTO> dtos)
        {
            Database db = null;

            try {
                db = Common.CurrentDatabase;
                db.KeepConnection = true;
                db.BeginTransaction(IsolationLevel.Serializable);

                MRPDDAO dao = new MRPDDAO(db);

                foreach (MRPDDTO dto in dtos)
                {
                    dao.AddNew(null, dto);
                }

                db.Commit();
            }
            catch (Exception) {
                db.Rollback();
                throw;
            }
            finally {
                if (db.DBConnectionState == ConnectionState.Open)
                {
                    db.Close();
                }
            }
        }
Esempio n. 2
0
        public NZDateTime GetMaxMRPDate()
        {
            MRPDDAO    dao = new MRPDDAO(Common.CurrentDatabase);
            NZDateTime dtm = dao.LoadMaxMRPDate(null);

            if (!dtm.IsNull)
            {
                DateTime d = new DateTime(dtm.StrongValue.Year, dtm.StrongValue.Month, 1);
                return(new NZDateTime(null, d.AddMonths(1).AddDays(-1)));
            }

            return(new NZDateTime(null, new DateTime(2999, 12, 31)));
        }
Esempio n. 3
0
        public DataTable LoadMRPDetailSummaryByMonth(string strMRP_NO, string strITEM_CD, string strLOC_CD)
        {
            MRPDDAO dao = new MRPDDAO(Common.CurrentDatabase);

            return(dao.LoadMRPDetailSummaryByMonth(null, strMRP_NO, strITEM_CD, strLOC_CD, Common.CurrentUserInfomation.DateFormat.ToString()));
        }
Esempio n. 4
0
        public DataTable LoadMRPDByItem(NZString strMRP_NO, NZString strITEM_CD, NZString strLOC_CD, NZDateTime dtmPERIOD_BEGIN, NZDateTime dtmPERIOD_END)
        {
            MRPDDAO dao = new MRPDDAO(Common.CurrentDatabase);

            return(dao.LoadMRPDetailByItem(null, strMRP_NO, strITEM_CD, strLOC_CD, dtmPERIOD_BEGIN, dtmPERIOD_END));
        }
Esempio n. 5
0
        public List <MRPDDTO> LoadMRPD(string strMRP_NO)
        {
            MRPDDAO dao = new MRPDDAO(Common.CurrentDatabase);

            return(dao.LoadMRPDetail(null, strMRP_NO));
        }
Esempio n. 6
0
        public void SaveData(MRPHDTO dtoHeader, List <MRPDDTO> dtoInsert, List <MRPDDTO> dtoUpdate, List <MRPDDTO> dtoDelete)
        {
            try {
                CheckBeforeSave();

                Common.CurrentDatabase.KeepConnection = true;
                Common.CurrentDatabase.BeginTransaction(IsolationLevel.Serializable);

                //Update Header
                MRPHDAO daoMRPH = new MRPHDAO(Common.CurrentDatabase);
                daoMRPH.UpdateMRPRevision(null, dtoHeader);

                MRPDDAO daoMRPD = new MRPDDAO(Common.CurrentDatabase);

                if (dtoDelete != null && dtoDelete.Count > 0)
                {
                    foreach (MRPDDTO dto in dtoDelete)
                    {
                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_DATE    = DateTime.Now.ToNZDateTime();
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_DATE    = DateTime.Now.ToNZDateTime();
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                        daoMRPD.Delete(null, dto.MRP_NO, dto.ITEM_CD, dto.ORDER_LOC_CD, dto.AT_DATE);
                    }
                }

                if (dtoInsert != null && dtoInsert.Count > 0)
                {
                    foreach (MRPDDTO dto in dtoInsert)
                    {
                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_DATE    = DateTime.Now.ToNZDateTime();
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_DATE    = DateTime.Now.ToNZDateTime();
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                        daoMRPD.AddNewOrUpdate(null, dto);
                    }
                }

                if (dtoUpdate != null && dtoUpdate.Count > 0)
                {
                    foreach (MRPDDTO dto in dtoUpdate)
                    {
                        dto.CRT_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.CRT_DATE    = DateTime.Now.ToNZDateTime();
                        dto.CRT_MACHINE = Common.CurrentUserInfomation.Machine;
                        dto.UPD_BY      = Common.CurrentUserInfomation.UserCD;
                        dto.UPD_DATE    = DateTime.Now.ToNZDateTime();
                        dto.UPD_MACHINE = Common.CurrentUserInfomation.Machine;
                        daoMRPD.AddNewOrUpdate(null, dto);
                    }
                }

                //Call Update Balance Stock
                daoMRPD.UpdateBalanceStock(null, dtoHeader);

                Common.CurrentDatabase.Commit();
            }
            catch (Exception) {
                Common.CurrentDatabase.Rollback();
                throw;
            }
        }