Пример #1
0
        public void DoInsertWorkOrder(tinpworkorder workorder,
            List<tinpworkorderdtl> lstDtl)
        {
            try
            {
                dbInstance.BeginTransaction();
                baseDal.DoInsert(workorder);

                WorkOrderDtlDal dtlDal = new WorkOrderDtlDal(dbInstance);
                CustOrderDal custOrderDal = new CustOrderDal(dbInstance);
                for (int i = 0; i < lstDtl.Count; i++)
                {
                    dtlDal.DoInsert<tinpworkorderdtl>(lstDtl[i]);
                }

                dbInstance.Commit();
            }
            catch (Exception ex)
            {
                dbInstance.Rollback();
                throw ex;
            }
            finally
            {
                dbInstance.CloseConnection();
            }
        }
Пример #2
0
        public void DoUpdateWorkOrder(tinpworkorder workorder,
            List<tinpworkorderdtl> lstDtl)
        {
            try
            {
                dbInstance.BeginTransaction();
                baseDal.DoUpdate(workorder);

                WorkOrderDtlDal dtlDal = new WorkOrderDtlDal(dbInstance);
                CustOrderDal custOrderDal = new CustOrderDal(dbInstance);
                for (int i = 0; i < lstDtl.Count; i++)
                {
                    List<MESParameterInfo> lstParams = new List<MESParameterInfo>() {
                            new MESParameterInfo(){ParamName="custorderno",ParamValue=lstDtl[i].custorderno},
                            new MESParameterInfo(){ParamName="styleno",ParamValue=lstDtl[i].styleno},
                            new MESParameterInfo(){ParamName="checktype",ParamValue=lstDtl[i].checktype}
                        };

                    #region check work order detail
                    List<tinpworkorderdtl> lstWorkOrderDtl = baseDal.GetSelectedObjects<tinpworkorderdtl>(lstParams, string.Empty, true, -1);
                    if (lstWorkOrderDtl.Count <= 0)
                    {
                        //insert
                        dtlDal.DoInsert<tinpworkorderdtl>(lstDtl[i]);
                    }
                    else
                    {
                        //update
                        lstWorkOrderDtl[0].schcartonqty = lstDtl[i].schcartonqty;
                        lstWorkOrderDtl[0].checktype = lstDtl[i].checktype;
                        lstWorkOrderDtl[0].completedtime = lstDtl[i].completedtime;
                        lstWorkOrderDtl[0].completeduser = lstDtl[i].completeduser;
                        lstWorkOrderDtl[0].schshpdate = lstDtl[i].schshpdate;
                        lstWorkOrderDtl[0].custorderno = lstDtl[i].custorderno;
                        lstWorkOrderDtl[0].schdlydate = lstDtl[i].schdlydate;
                        lstWorkOrderDtl[0].schpairqty = lstDtl[i].schpairqty;
                        lstWorkOrderDtl[0].remark = lstDtl[i].remark;
                        lstWorkOrderDtl[0].styleno = lstDtl[i].styleno;
                        lstWorkOrderDtl[0].workorderlineno = lstDtl[i].workorderlineno;
                        lstWorkOrderDtl[0].workordersysid = lstDtl[i].workordersysid;

                        dtlDal.DoUpdate<tinpworkorderdtl>(lstWorkOrderDtl[0]);
                    }
                    #endregion
                }

                #region check delete
                CheckDelete(custOrderDal, dtlDal, workorder, lstDtl);
                #endregion

                dbInstance.Commit();
            }
            catch (Exception ex)
            {
                dbInstance.Rollback();
                throw ex;
            }
            finally
            {
                dbInstance.CloseConnection();
            }
        }
Пример #3
0
        private void CheckDelete(CustOrderDal custOrderDal,WorkOrderDtlDal dtlDal,
            tinpworkorder workorder,List<tinpworkorderdtl> lstDtl)
        {
            List<MESParameterInfo> lstParams = new List<MESParameterInfo>() {
                            new MESParameterInfo(){ParamName="workordersysid",ParamValue=workorder.workordersysid}
                        };

            List<tinpworkorderdtl> lstOldDtl = dtlDal.GetSelectedObjects<tinpworkorderdtl>(lstParams, string.Empty, true, -1);
            for (int i = 0; i < lstOldDtl.Count; i++)
            {
                var q = (from p in lstDtl
                         where p.custorderno == lstOldDtl[i].custorderno
                         && p.styleno == lstOldDtl[i].styleno
                         && p.checktype == lstOldDtl[i].checktype
                         select p).ToList();
                if (q.Count <= 0)
                {
                    //need to delete

                    //do delete
                    dtlDal.DoDelete<tinpworkorderdtl>(lstParams);
                }
            }
        }
Пример #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the tinpworkorder EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotinpworkorder(tinpworkorder tinpworkorder)
 {
     base.AddObject("tinpworkorder", tinpworkorder);
 }
Пример #5
0
 /// <summary>
 /// Create a new tinpworkorder object.
 /// </summary>
 /// <param name="workordersysid">Initial value of the workordersysid property.</param>
 /// <param name="workorderno">Initial value of the workorderno property.</param>
 public static tinpworkorder Createtinpworkorder(global::System.String workordersysid, global::System.String workorderno)
 {
     tinpworkorder tinpworkorder = new tinpworkorder();
     tinpworkorder.workordersysid = workordersysid;
     tinpworkorder.workorderno = workorderno;
     return tinpworkorder;
 }
Пример #6
0
 public void DoUpdateWorkOrder(ContextInfo contextInfo, tinpworkorder workorder,
     List<tinpworkorderdtl> lstDtl)
 {
     contextInfo.Action = MES_ActionType.Update;
     WorkOrderBll bll = new WorkOrderBll(contextInfo);
     bll.CallAccessControl();
     bll.DoUpdateWorkOrder(workorder, lstDtl);
     GC.Collect();
 }