예제 #1
0
        public Equ_PmRecordInfo GetEquPmUnFinishRecordDetailObj(Equ_PmRecordInfo equinfo, Equ_PmRecordInfo result)
        {
            DataTable dt          = new DataTable();
            string    ReturnValue = string.Empty;

            using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ELCO_ConnectionString"].ToString()))
            {
                SqlCommand cmd = new SqlCommand();
                conn.Open();
                cmd.Connection = conn;
                string str1 = "select a.ID,b.ProcessName as ProcessCode,a.DeviceName,a.PmPlanName,a.PmSpecName from Equ_PmPlanList a  left join Mes_Process_List b on a.ProcessCode=b.ProcessCode";
                if (equinfo.ID != "")
                {
                    str1 += " WHERE a.ID = " + equinfo.ID + " ";
                }
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = str1;
                SqlDataAdapter Datapter = new SqlDataAdapter(cmd);
                Datapter.Fill(dt);

                if (dt != null && dt.Rows.Count > 0)
                {
                    result.ID           = dt.Rows[0]["ID"].ToString();
                    result.ProcessCode  = dt.Rows[0]["ProcessCode"].ToString();
                    result.DeviceName   = dt.Rows[0]["DeviceName"].ToString();
                    result.PmPlanName   = dt.Rows[0]["PmPlanName"].ToString();
                    result.PmSpecName   = dt.Rows[0]["PmSpecName"].ToString();
                    result.PmStartDate  = "";
                    result.PmFinishDate = "";
                    result.PmComment    = "";
                    result.PmOper       = "";
                }
            }
            return(result);
        }
예제 #2
0
 public ResultMsg_Equ_PmRecord editEquMaintenceManDataInDB(Equ_PmRecordInfo dataEntity, ResultMsg_Equ_PmRecord result)
 {
     if (dataEntity.ID.Length == 0)
     {
         dataEntity.ID = "0";
     }
     using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ELCO_ConnectionString"].ToString()))
     {
         SqlCommand     cmd         = new SqlCommand();
         SqlTransaction transaction = null;
         try
         {
             conn.Open();
             cmd.Connection = conn;
             string strSql = "";
             transaction     = conn.BeginTransaction();
             cmd.Transaction = transaction;
             strSql          = string.Format(
                 @" UPDATE Equ_PmRecordList SET 
                                       PmStartDate= '{1}'
                                     , PmFinishDate= '{2}'
                                     , PmOper= '{3}'
                                     , PmComment= '{4}'
                                     , UpdateUser   = '******'
                                     , UpdateTime   = getdate()
                                     WHERE id = {6}
                                 ",
                 dataEntity.PmStartDate,
                 dataEntity.PmFinishDate,
                 dataEntity.PmOper,
                 dataEntity.PmComment,
                 UserName,
                 dataEntity.ID
                 );
             cmd.CommandType = CommandType.Text;
             cmd.CommandText = strSql;
             cmd.ExecuteNonQuery();
             transaction.Commit();
             result.result = "success";
             result.msg    = "保存数据成功!";
         }
         catch (Exception ex)
         {
             transaction.Rollback();
             result.result = "failed";
             result.msg    = "保存失败! \n" + ex.Message;
         }
     }
     return(result);
 }
예제 #3
0
        public ResultMsg_Equ_PmRecord ExcuteEquMaintenceManDataInDB(Equ_PmRecordInfo dataEntity, ResultMsg_Equ_PmRecord result)
        {
            if (dataEntity.ProcessCode.Length == 0)
            {
                dataEntity.ProcessCode = "";
            }
            if (dataEntity.DeviceName.Length == 0)
            {
                dataEntity.DeviceName = "";
            }
            if (dataEntity.PmOper.Length == 0)
            {
                dataEntity.PmOper = "";
            }
            if (dataEntity.PmSpecName.Length == 0)
            {
                dataEntity.PmSpecName = "";
            }
            if (dataEntity.PmStartDate.Length == 0)
            {
                dataEntity.PmStartDate = "";
            }
            if (dataEntity.PmFinishDate.Length == 0)
            {
                dataEntity.PmFinishDate = "";
            }
            if (dataEntity.PmComment.Length == 0)
            {
                dataEntity.PmComment = "";
            }
            //if (dataEntity.PmType.Length == 0) dataEntity.PmType = "计划外保养";
            using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ELCO_ConnectionString"].ToString()))
            {
                SqlCommand     cmd         = new SqlCommand();
                SqlTransaction transaction = null;
                try
                {
                    conn.Open();
                    cmd.Connection = conn;
                    string strSql = "";

                    transaction     = conn.BeginTransaction();
                    cmd.Transaction = transaction;

                    strSql = string.Format(
                        @" INSERT INTO Equ_PmRecordList  
                    (  ProcessCode, DeviceName,PmSpecName,PmType,PmStartDate,PmFinishDate,PmOper,PmComment,UpdateUser,UpdateTime,PmPlanName,PmLevel,PmPlanDate,PmDoTimes)VALUES (
                      (select ProcessCode from Mes_Process_List where ProcessName='" + dataEntity.ProcessCode + "'),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',getdate(),'{8}',(select PmLevel from Equ_PmSpecList where PmSpecName='" + dataEntity.PmSpecName + "'),'" + RequstString("PmFirstDate") + "','" + RequstString("PmDoTimes") + "') ",
                        dataEntity.DeviceName,
                        dataEntity.PmSpecName,
                        dataEntity.PmType,
                        dataEntity.PmStartDate,
                        dataEntity.PmFinishDate,
                        dataEntity.PmOper,
                        dataEntity.PmComment,
                        UserName,
                        dataEntity.PmPlanName

                        );
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = strSql;
                    cmd.ExecuteNonQuery();
                    transaction.Commit();
                    result.result = "success";
                    result.msg    = "保存数据成功!";
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    result.result = "failed";
                    result.msg    = "保存失败! \n" + ex.Message;
                }
            }
            return(result);
        }
예제 #4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (context.Session["UserName"] != null)
            {
                UserName = context.Session["UserName"].ToString().ToUpper().Trim();
            }
            else
            {
                UserName = "";
            }

            Action = RequstString("Action");

            if (Action.Length == 0)
            {
                Action = "";
            }

            if (Action == "EquMaintenceExtraMan_Detail" || Action == "EquMaintenceMan_DetailFinish")
            {
                Equ_PmRecordInfo equinfo = new Equ_PmRecordInfo();
                equinfo.ID = RequstString("EquID");
                Equ_PmRecordInfo result = new Equ_PmRecordInfo();
                result = GetEquPmRecordDetailObj(equinfo, result);
                context.Response.Write(jsc.Serialize(result));
            }
            else if (Action == "EquMaintenceExtraMan_Edit")
            {
                Equ_PmRecordInfo dataEntity = new Equ_PmRecordInfo();
                dataEntity.ID           = RequstString("EquID");
                dataEntity.ProcessCode  = RequstString("ProcessName");
                dataEntity.DeviceName   = RequstString("DeviceName");
                dataEntity.PmSpecName   = RequstString("PmSpecName");
                dataEntity.PmStartDate  = RequstString("PmStartDate");
                dataEntity.PmFinishDate = RequstString("PmFinishDate");
                dataEntity.PmOper       = RequstString("PmOper");
                dataEntity.PmComment    = RequstString("PmComment");

                ResultMsg_Equ_PmRecord result = new ResultMsg_Equ_PmRecord();
                result = editEquMaintenceExtraManDataInDB(dataEntity, result);
                context.Response.Write(jsc.Serialize(result));
            }
            else if (Action == "EquMaintenceExtraMan_Add")
            {
                Equ_PmRecordInfo dataEntity = new Equ_PmRecordInfo();
                //dataEntity.ID = RequstString("ProcId");
                dataEntity.ProcessCode  = RequstString("ProcessName");
                dataEntity.DeviceName   = RequstString("DeviceName");
                dataEntity.PmType       = RequstString("PmType");
                dataEntity.PmSpecName   = RequstString("PmSpecName");
                dataEntity.PmStartDate  = RequstString("PmStartDate");
                dataEntity.PmFinishDate = RequstString("PmFinishDate");
                dataEntity.PmComment    = RequstString("PmComment");
                dataEntity.PmOper       = RequstString("PmOper");

                ResultMsg_Equ_PmRecord result = new ResultMsg_Equ_PmRecord();
                result = addEquMaintenceExtraManDataInDB(dataEntity, result);
                context.Response.Write(jsc.Serialize(result));
            }

            else if (Action == "EquMaintenceMan_DetailUnFinish")
            {
                Equ_PmRecordInfo equinfo = new Equ_PmRecordInfo();
                equinfo.ID = RequstString("EquID");
                Equ_PmRecordInfo result = new Equ_PmRecordInfo();
                result = GetEquPmUnFinishRecordDetailObj(equinfo, result);
                context.Response.Write(jsc.Serialize(result));
            }

            else if (Action == "ExcuteEquMaintenceMan")
            {
                Equ_PmRecordInfo dataEntity = new Equ_PmRecordInfo();
                //dataEntity.ID = RequstString("EquID");
                dataEntity.ProcessCode  = RequstString("ProcessName");
                dataEntity.DeviceName   = RequstString("DeviceName");
                dataEntity.PmSpecName   = RequstString("PmSpecName");
                dataEntity.PmPlanName   = RequstString("PmPlanName");
                dataEntity.PmType       = "计划内保养";
                dataEntity.PmSpecName   = RequstString("PmSpecName");
                dataEntity.PmStartDate  = RequstString("PmStartDate");
                dataEntity.PmFinishDate = RequstString("PmFinishDate");
                dataEntity.PmComment    = RequstString("PmComment");
                dataEntity.PmOper       = RequstString("PmOper");

                ResultMsg_Equ_PmRecord result = new ResultMsg_Equ_PmRecord();
                result = ExcuteEquMaintenceManDataInDB(dataEntity, result);
                context.Response.Write(jsc.Serialize(result));
            }

            else if (Action == "EquMaintenceManEdit")
            {
                Equ_PmRecordInfo dataEntity = new Equ_PmRecordInfo();
                dataEntity.ID = RequstString("EquID");
                //dataEntity.ProcessCode = RequstString("ProcessName");
                //dataEntity.DeviceName = RequstString("DeviceName");
                //dataEntity.PmSpecName = RequstString("PmSpecName");
                //dataEntity.PmPlanName = RequstString("PmPlanName");
                //dataEntity.PmType = "计划内保养";
                //dataEntity.PmSpecName = RequstString("PmSpecName");
                dataEntity.PmStartDate  = RequstString("PmStartDate");
                dataEntity.PmFinishDate = RequstString("PmFinishDate");
                dataEntity.PmComment    = RequstString("PmComment");
                dataEntity.PmOper       = RequstString("PmOper");

                ResultMsg_Equ_PmRecord result = new ResultMsg_Equ_PmRecord();
                result = editEquMaintenceManDataInDB(dataEntity, result);
                context.Response.Write(jsc.Serialize(result));
            }

            else if (Action == "ExcuteFirstLevelEquMaintenceMan")
            {
                List <Equ_PmFisrtLevelRecordInfo> dataEntity = new List <Equ_PmFisrtLevelRecordInfo>();
                string[] PmList = RequstString("PmList").Split(',');

                for (int i = 0; i < PmList.Length; i++)
                {
                    Equ_PmFisrtLevelRecordInfo ep = new Equ_PmFisrtLevelRecordInfo();
                    ep.PmPlanCode = PmList[i].ToString();

                    ep.PmComment = RequstString("PmComment");
                    ep.PmOper    = RequstString("PmOper");

                    ep.FindProblem   = RequstString("FindProblem") == "" ? 0 : Convert.ToInt16(RequstString("FindProblem"));
                    ep.RepairProblem = RequstString("RepairProblem") == "" ? 0 : Convert.ToInt16(RequstString("RepairProblem"));
                    ep.ReaminProblem = RequstString("ReaminProblem") == "" ? 0 : Convert.ToInt16(RequstString("ReaminProblem"));
                    dataEntity.Add(ep);
                }

                ResultMsg_Equ_PmFirstLevelRecord result = new ResultMsg_Equ_PmFirstLevelRecord();
                result = ExcuteFirstLevelEquMaintenceMan(dataEntity, result);
                context.Response.Write(jsc.Serialize(result));
            }

            else if (Action == "ExcuteSecondLevelEquMaintenceMan")
            {
                List <Equ_PmFisrtLevelRecordInfo> dataEntity = new List <Equ_PmFisrtLevelRecordInfo>();
                string[] PmList = RequstString("PmList").Split(',');

                for (int i = 0; i < PmList.Length; i++)
                {
                    Equ_PmFisrtLevelRecordInfo ep = new Equ_PmFisrtLevelRecordInfo();
                    ep.PmPlanCode = PmList[i].ToString();
                    ep.PmOper     = RequstString("PmOper");
                    dataEntity.Add(ep);
                }

                ResultMsg_Equ_PmFirstLevelRecord result = new ResultMsg_Equ_PmFirstLevelRecord();
                result = ExcuteSecondLevelEquMaintenceMan(dataEntity, result);
                context.Response.Write(jsc.Serialize(result));
            }

            else if (Action == "CheckFirstLevelMaintence")
            {
                ResultMsg_Equ_PmFirstLevelRecord result = new ResultMsg_Equ_PmFirstLevelRecord();
                result = CheckFirstLevelMaintence(result);
                context.Response.Write(jsc.Serialize(result));
            }

            else if (Action == "EquFirstLevelMaintenceMan_Detail")
            {
                Equ_PmFisrtLevelRecordDetail result = new Equ_PmFisrtLevelRecordDetail();
                result.ID = RequstString("EquID");
                result    = GetFirstLevelDetail(result);
                context.Response.Write(jsc.Serialize(result));
            }

            else if (Action == "AddSecondLevelProblem")
            {
                Equ_PmSecondLevelProblem dataEntity = new Equ_PmSecondLevelProblem();
                //dataEntity.ID = RequstString("EquID");
                dataEntity.PmOper            = RequstString("PmOper");
                dataEntity.PmDate            = RequstString("PmDate");
                dataEntity.DeviceCode        = RequstString("DeviceCode");
                dataEntity.MaintenceTime     = RequstString("MaintenceTime");
                dataEntity.PowerLine         = RequstString("PowerLine");
                dataEntity.GroundLead        = RequstString("GroundLead");
                dataEntity.ReplacePart       = RequstString("ReplacePart");
                dataEntity.ReplaceName       = RequstString("ReplaceName");
                dataEntity.ReplaceCount      = RequstString("ReplaceCount");
                dataEntity.InspectionProblem = RequstString("InspectionProblem");

                ResultMsg_Equ_PmFirstLevelRecord result = new ResultMsg_Equ_PmFirstLevelRecord();
                result = AddSecondLevelProblem(dataEntity, result);
                context.Response.Write(jsc.Serialize(result));
            }

            #region//获取每日保养用时
            if (Action == "GetDailyMaintenceTime")
            {
                Model.DailyMaintenceTime mb = new Model.DailyMaintenceTime();
                mb.MaintenceDate = RequstString("CurrentMonth");
                mb = GetDailyMaintenceTime(mb);
                context.Response.Write(jsc.Serialize(mb));
            }
            #endregion
            #region //新增每日保养用时
            if (Action == "DailyMaintenceTime_Add")
            {
                Model.DailyMaintenceTime mb = new Model.DailyMaintenceTime();
                mb.MaintenceDate = RequstString("CurrentTime");
                mb.TotalTime     = RequstString("TotalTime");
                Model.ResultMsg_DailyMaintenceTime result = new ResultMsg_DailyMaintenceTime();
                result = DailyMaintenceTimeAdd(mb, result);
                context.Response.Write(jsc.Serialize(result));
            }
            #endregion
            #region //更新每日保养用时
            if (Action == "DailyMaintenceTime_Edit")
            {
                Model.DailyMaintenceTime mb = new Model.DailyMaintenceTime();
                mb.MaintenceDate = RequstString("CurrentMonth");
                mb.TotalTime     = RequstString("TotalTime");
                Model.ResultMsg_DailyMaintenceTime result = new Model.ResultMsg_DailyMaintenceTime();
                result = DailyMaintenceTimeEdit(mb, result);
                context.Response.Write(jsc.Serialize(result));
            }
            #endregion
        }