Esempio n. 1
0
        public static List<KanbanList> getKanbanList(ref int totalRecord,int? pageindex = null,int? pagesize = null)
        {
            List<KanbanList> result = new List<KanbanList>();
            using (TAC_KANBANEntities ef = new TAC_KANBANEntities())
            {
                try
                {
                    var query = from kb in ef.EXT_KANBAN
                                join mds in ef.MA_MODEL_STRUCTURE on kb.MODEL_STRUCTURE_ID equals mds.ID
                                join m in ef.MA_MODEL on mds.MODEL_ID equals m.ID
                                where (kb.STATUS == null)
                                select new KanbanList
                                {
                                    KanbnaId = kb.ID,
                                    customer_name = m.MA_CUSTOMER.CUSTOMER_NAME,
                                    model_name = m.MODEL_NAME,
                                    part_name = mds.MA_PART.PART_NAME,
                                    part_no = mds.MA_PART.PART_NO,
                                    tag_id = kb.TAG_ID,
                                    quantity = mds.LOT_SIZE,
                                    total_quantity = kb.EXT_PLAN.LOT_SIZE
                                };
                    totalRecord = query.Count();
                    if (pageindex.HasValue && pagesize.HasValue)
                    {
                        if (query.Any())
                        {
                            IQueryable<KanbanList> iqQuery = query.AsQueryable().OrderBy(x => x.customer_name);
                            result = iqQuery.Skip(pagesize.Value * (pageindex.Value - 1)).Take(pagesize.Value).ToList();
                        }
                    }
                    else if (query.Any())
                    {
                        result = query.ToList();
                    }
                }
                catch
                {

                }
            }

            return result;
        }
Esempio n. 2
0
        public static List<Part> getPartsList(ref int totalRecord, int? pageindex = null, int? pagesize = null)
        {
            List<Part> result = new List<Part>();
            using (TAC_KANBANEntities ef = new TAC_KANBANEntities())
            {
                try
                {
                    var query = from mp in ef.MA_PART
                                select new Part
                                {
                                    ID = mp.ID,
                                    PART_NAME = mp.PART_NAME,
                                    PART_NO = mp.PART_NO,
                                    PROD_LENGTH = mp.PROD_LENGTH,
                                    PART_TYPE = mp.PACKING_TYPE,
                                    UNIT_QTY = mp.PACK_PCS_LOT,
                                };
                    totalRecord = query.Count();
                    if (pageindex.HasValue && pagesize.HasValue)
                    {
                        if (query.Any())
                        {
                            IQueryable<Part> iqQuery = query.AsQueryable().OrderBy(x => x.ID);
                            result = iqQuery.Skip(pagesize.Value * (pageindex.Value - 1)).Take(pagesize.Value).ToList();
                        }
                    }
                    else if (query.Any())
                    {
                        result = query.ToList();
                    }
                }
                catch
                {

                }
            }

            return result;
        }
Esempio n. 3
0
        public static List<OperatorMaster> getOperatorMasterList(ref int totalRecord, int? pageindex = null, int? pagesize = null)
        {
            List<OperatorMaster> result = new List<OperatorMaster>();
            using (TAC_KANBANEntities ef = new TAC_KANBANEntities())
            {
                try
                {
                    var query = from mp in ef.MA_OPT_USER
                                join ro in ef.MA_OPT_ROLE on mp.ROLE_ID equals ro.ID
                                select new OperatorMaster
                                {
                                    id = mp.ID,
                                    username = mp.USER_NAME,
                                    password = mp.PASSWORD,
                                    roleid = mp.ROLE_ID,
                                    rolename = ro.DESCRIPTION
                                };
                    totalRecord = query.Count();
                    if (pageindex.HasValue && pagesize.HasValue)
                    {
                        if (query.Any())
                        {
                            IQueryable<OperatorMaster> iqQuery = query.AsQueryable().OrderBy(x => x.id);
                            result = iqQuery.Skip(pagesize.Value * (pageindex.Value - 1)).Take(pagesize.Value).ToList();
                        }
                    }
                    else if (query.Any())
                    {
                        result = query.ToList();
                    }
                }
                catch
                {

                }
            }

            return result;
        }
Esempio n. 4
0
        public static List<LineMaster> getLineList(ref int totalRecord, int? pageindex = null, int? pagesize = null)
        {
            List<LineMaster> result = new List<LineMaster>();
            using (TAC_KANBANEntities ef = new TAC_KANBANEntities())
            {
                try
                {
                    var query = from mp in ef.MA_LINE
                                select new LineMaster
                                {
                                    id = mp.ID,
                                    Line = mp.LINE_NAME,
                                    Process = mp.PROCESS_NAME,
                                    Sequence = mp.PROCESS_SEQ
                                };
                    totalRecord = query.Count();
                    if (pageindex.HasValue && pagesize.HasValue)
                    {
                        if (query.Any())
                        {
                            IQueryable<LineMaster> iqQuery = query.AsQueryable().OrderBy(x => x.id);
                            result = iqQuery.Skip(pagesize.Value * (pageindex.Value - 1)).Take(pagesize.Value).ToList();
                        }
                    }
                    else if (query.Any())
                    {
                        result = query.ToList();
                    }
                }
                catch
                {

                }
            }

            return result;
        }
Esempio n. 5
0
        public static List<OpeatorRoleMaster> getOperatorRoleList(ref int totalRecord, int? pageindex = null, int? pagesize = null)
        {
            List<OpeatorRoleMaster> result = new List<OpeatorRoleMaster>();
            using (TAC_KANBANEntities ef = new TAC_KANBANEntities())
            {
                try
                {
                    var query = from mp in ef.MA_OPT_ROLE
                                select new OpeatorRoleMaster
                                {
                                    id = mp.ID,
                                    rolename = mp.ROLE_NAME,
                                    description = mp.DESCRIPTION
                                };
                    totalRecord = query.Count();
                    if (pageindex.HasValue && pagesize.HasValue)
                    {
                        if (query.Any())
                        {
                            IQueryable<OpeatorRoleMaster> iqQuery = query.AsQueryable().OrderBy(x => x.id);
                            result = iqQuery.Skip(pagesize.Value * (pageindex.Value - 1)).Take(pagesize.Value).ToList();
                        }
                    }
                    else if (query.Any())
                    {
                        result = query.ToList();
                    }
                }
                catch
                {

                }
            }

            return result;
        }
Esempio n. 6
0
        public static List<CustomerMaster> getCustomerMasterList(ref int totalRecord, int? pageindex = null, int? pagesize = null)
        {
            List<CustomerMaster> result = new List<CustomerMaster>();
            using (TAC_KANBANEntities ef = new TAC_KANBANEntities())
            {
                try
                {
                    var query = from mp in ef.MA_CUSTOMER
                                select new CustomerMaster
                                {
                                    id = mp.ID,
                                    customer_name = mp.CUSTOMER_NAME,
                                    customer_shortname = mp.CUSTOMER_SHOT
                                };
                    totalRecord = query.Count();
                    if (pageindex.HasValue && pagesize.HasValue)
                    {
                        if (query.Any())
                        {
                            IQueryable<CustomerMaster> iqQuery = query.AsQueryable().OrderBy(x => x.id);
                            result = iqQuery.Skip(pagesize.Value * (pageindex.Value - 1)).Take(pagesize.Value).ToList();
                        }
                    }
                    else if (query.Any())
                    {
                        result = query.ToList();
                    }
                }
                catch
                {

                }
            }

            return result;
        }
Esempio n. 7
0
        public static string Update(FORECAST_ORDER fc, TAC_KANBANEntities ceRef = null)
        {
            String results = null;
            bool isSuccess = false;
            bool isRootTransaction = true;

            TAC_KANBANEntities ce;
            if (ceRef == null)
            {
                //using new entity object
                ce = new TAC_KANBANEntities();
            }
            else
            {
                //using current entity object
                ce = ceRef;
                isRootTransaction = false;
            }

            // Start transaction for update a Lease Admin record.
            try
            {
                using (TransactionScope trans = EntityUtils.CreateTransactionScope())
                {
                    if (isRootTransaction)
                    {
                        // Manually open connection to prevent EF from auto closing
                        // connection and causing issues with future queries.
                        ce.Connection.Open();
                    }

                    // Checking for version
                    ce.AttachUpdated(fc);
                    ce.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave);

                    isSuccess = true;
                    trans.Complete();     // Transaction complete
                }
            }
            catch (OptimisticConcurrencyException oex)
            {
                // Log error in ELMAH for any diagnostic needs.

                results = "The current record has been modifed since you have " +
                          "last retrieved it. Please reload the record and " +
                          "attempt to save it again.";
            }
            catch (Exception ex)
            {
                // Error occurs
                // Log error in ELMAH for any diagnostic needs.

                isSuccess = false;
                results = "An error occurred saving the record. Please try again.";
            }
            finally
            {
                if (isRootTransaction)
                {
                    ce.Connection.Dispose();
                }
            }

            // Finally accept all changes from the transaction.
            if (isSuccess && isRootTransaction)
            {
                ce.Dispose();
            }

            return results;
        }
Esempio n. 8
0
        public static String Delete(int id, TAC_KANBANEntities ceRef = null)
        {
            String sResult = null;
            bool isSuccess = false;
            bool isRootTransaction = true;

            TAC_KANBANEntities ce;
            if (ceRef == null)
            {
                //using new entity object
                ce = new TAC_KANBANEntities();
            }
            else
            {
                //using current entity object
                ce = ceRef;
                isRootTransaction = false;
            }

            try
            {
                using (TransactionScope trans = EntityUtils.CreateTransactionScope())
                {
                    if (isRootTransaction)
                    {
                        // Manually open connection to prevent EF from auto closing
                        // connection and causing issues with future queries.
                        ce.Connection.Open();
                    }

                    var forecastDetail = from com in ce.FORECAST_ORDER_DETAIL
                                           where com.FORCAST_ID == id
                                           select com;

                    if (forecastDetail.Count() > 0)
                    {
                        foreach (FORECAST_ORDER_DETAIL item in forecastDetail.ToList<FORECAST_ORDER_DETAIL>())
                        {
                            ce.DeleteObject(item);
                        }
                    }

                    //Delete record
                    var forecast = from doc in ce.FORECAST_ORDER
                                   where doc.ID == id
                                   select doc;

                    if (forecast.Any())
                    {
                        FORECAST_ORDER fc = forecast.FirstOrDefault();
                        ce.FORECAST_ORDER.DeleteObject(fc);
                    }
                    else
                    {
                        throw new NullReferenceException();
                    }

                    if (isRootTransaction)
                    {
                        // We tentatively save the changes so that we can finish
                        // processing the transaction.foreach (var bk in books)
                        ce.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave);
                    }

                    isSuccess = true;
                    trans.Complete();     //Transaction complete.
                }
            }
            catch (Exception ex)
            {
                // Log error in ELMAH for any diagnostic needs.

                sResult = ex.ToString();
                isSuccess = false;
            }
            finally
            {
                if (isRootTransaction)
                {
                    ce.Connection.Dispose();
                }
            }

            // Finally accept all changes from the transaction.
            if (isSuccess && isRootTransaction)
            {
                ce.AcceptAllChanges();
                ce.Dispose();
            }

            return sResult;
        }