Example #1
0
        public void DeleteKeyPart(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec       sfcdb = null;
            T_C_KEYPART   ketpart;
            Row_C_KEYPART newketpart;

            string[] ids = Data["ID"].ToString().Trim().Split(',');
            string   SQL = "";

            sfcdb = this.DBPools["SFCDB"].Borrow();
            sfcdb.BeginTrain();
            try
            {
                foreach (string id in ids)
                {
                    ketpart    = new T_C_KEYPART(sfcdb, DBTYPE);
                    newketpart = (Row_C_KEYPART)ketpart.GetObjByID(id, sfcdb);
                    SQL       += newketpart.GetDeleteString(DB_TYPE_ENUM.Oracle) + ";\n";
                }
                sfcdb.ExecSQL("Begin\n" + SQL + "End;");
                sfcdb.CommitTrain();
                this.DBPools["SFCDB"].Return(sfcdb);
                StationReturn.Status  = StationReturnStatusValue.Pass;
                StationReturn.Message = "刪除成功!!";
                this.DBPools["SFCDB"].Return(sfcdb);
            }
            catch (Exception e)
            {
                sfcdb.RollbackTrain();
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "刪除失敗!!";
                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
                throw e;
            }
        }
Example #2
0
        public void UpdateKeyPart(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec       sfcdb = null;
            T_C_KEYPART   ketpart;
            Row_C_KEYPART upketpart;
            string        Id           = Data["ID"].ToString().Trim();
            string        KeyPartId    = Data["KEYPART_ID"].ToString().Trim();
            string        SeqNo        = Data["SEQ_NO"].ToString().Trim();
            string        PartNo       = Data["PART_NO"].ToString().Trim();
            string        PartNoVer    = Data["PART_NO_VER"].ToString().Trim();
            string        Qty          = Data["QTY"].ToString().Trim();
            string        StationName  = Data["STATION_NAME"].ToString().Trim();
            string        Category     = Data["CATEGORY"].ToString().Trim();
            string        CategoryName = Data["CATEGORY_NAME"].ToString().Trim();
            string        Skuno        = Data["SKUNO"].ToString().Trim();
            string        SkunoVer     = Data["SKUNO_VER"].ToString().Trim();

            try
            {
                if (Id.Length <= 0)
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("ID");
                    return;
                }
                if (KeyPartId.Length <= 0)
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("KEYPART_ID");
                    return;
                }

                if (SeqNo.Length <= 0)
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("SEQ_NO");
                    return;
                }
                if (PartNo.Length <= 0)
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("PART_NO");
                    return;
                }
                if (PartNoVer.Length <= 0)
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("PART_NO_VER");
                    return;
                }
                if (Qty.Length <= 0)
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("Qty");
                    return;
                }
                if (StationName.Length <= 0)
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("StationName");
                    return;
                }
                if (Category.Length <= 0)
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("Category");
                    return;
                }
                if (CategoryName.Length <= 0)
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("CategoryName");
                    return;
                }
                if (Skuno.Length <= 0)
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("Skuno");
                    return;
                }
                if (SkunoVer.Length <= 0)
                {
                    StationReturn.Status      = StationReturnStatusValue.Fail;
                    StationReturn.MessageCode = "MES00000006";
                    StationReturn.MessagePara.Add("SkunoVer");
                    return;
                }
                double?Seqno = Convert.ToDouble(SeqNo);
                double?qty   = Convert.ToDouble(Qty);
                sfcdb     = this.DBPools["SFCDB"].Borrow();
                ketpart   = new T_C_KEYPART(sfcdb, DBTYPE);
                upketpart = (Row_C_KEYPART)ketpart.GetObjByID(Id, sfcdb);
                if (upketpart.KEYPART_ID != null || upketpart.KEYPART_ID != "")
                {
                    upketpart.KEYPART_ID    = KeyPartId;
                    upketpart.SEQ_NO        = Seqno;
                    upketpart.PART_NO       = PartNo;
                    upketpart.PART_NO_VER   = PartNoVer;
                    upketpart.QTY           = qty;
                    upketpart.STATION_NAME  = StationName;
                    upketpart.CATEGORY      = Category;
                    upketpart.CATEGORY_NAME = CategoryName;
                    upketpart.SKUNO         = Skuno;
                    upketpart.SKUNO_VER     = SkunoVer;
                    upketpart.EDIT_EMP      = LoginUser.EMP_NO;
                    upketpart.EDIT_TIME     = GetDBDateTime();
                    int result = sfcdb.ExecuteNonQuery(upketpart.GetUpdateString(DB_TYPE_ENUM.Oracle), System.Data.CommandType.Text);
                    if (result > 0)
                    {
                        StationReturn.Status  = StationReturnStatusValue.Pass;
                        StationReturn.Message = "MES00000001";
                    }
                    else
                    {
                        StationReturn.Status      = StationReturnStatusValue.Fail;
                        StationReturn.MessageCode = "MES00000021";
                    }
                }
                this.DBPools["SFCDB"].Return(sfcdb);
            }
            catch (Exception e)
            {
                if (sfcdb != null)
                {
                    this.DBPools["SFCDB"].Return(sfcdb);
                }
                throw e;
            }
        }