Exemplo n.º 1
0
        public ResultMsg_Equ_PmPlan editEquMaintencePlanDataInDB(Equ_PmPlanInfo dataEntity, ResultMsg_Equ_PmPlan result)
        {
            if (dataEntity.ID.Length == 0)
            {
                dataEntity.ID = "0";
            }
            //if (dataEntity.ProcessCode.Length == 0) dataEntity.ProcessCode = "";
            //if (dataEntity.ProcessName.Length == 0) dataEntity.ProcessName = "";
            //if (dataEntity.ProcessBeat.Length == 0) dataEntity.ProcessBeat = "";
            //if (dataEntity.ProcessDsca.Length == 0) dataEntity.ProcessDsca = "";
            //if (dataEntity.InturnNumber.Length == 0) dataEntity.InturnNumber = "0";
            //if (dataEntity.ProcessManual.Length == 0) dataEntity.ProcessManual = "";
            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 = " SELECT COUNT(1) AS SM FROM Equ_PmPlanList WHERE PmPlanCode = '" + dataEntity.PmPlanCode + "' and ID <> " + dataEntity.ID;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = strSql;
                    SqlDataAdapter Datapter = new SqlDataAdapter(cmd);
                    DataTable      dt       = new DataTable();
                    Datapter.Fill(dt);

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        if (Convert.ToInt32(dt.Rows[0]["SM"]) > 0)
                        {
                            result.result = "failed";
                            result.msg    = "此保养计划编号已经存在, 请核对!";
                        }
                        else
                        {
                            result.result = "";
                            result.msg    = "";
                        }
                    }
                    else
                    {
                        result.result = "failed";
                        result.msg    = "数据重复性检查失败!";
                    }

                    if (result.result == "")
                    {
                        transaction     = conn.BeginTransaction();
                        cmd.Transaction = transaction;
                        strSql          = string.Format(
                            @" UPDATE Equ_PmPlanList SET 
                                                  ProcessCode  = '{0}' 
                                                , PmLevel ='{1}'
                                                , DeviceName  = '{2}'
                                                , PmSpecCode = '{3}'
                                                , PmPlanCode= '{4}'
                                                , PmPlanName= '{5}'
                                                , PmCycleTime= '{6}'
                                                , PmTimeUsage= '{7}'
                                                , PmFirstDate= '{8}'
                                                , PmContinueTimes= '{9}'
                                                , PmPreAlarmDates= '{10}'
                                                , PmPlanComment= '{11}'
                                                , UpdateUser   = '******'
                                                , UpdateTime   = getdate()
                                                WHERE id = {13}
                                            ",
                            dataEntity.ProcessCode,
                            dataEntity.PmLevel,
                            dataEntity.DeviceName,
                            dataEntity.PmSpecName,
                            dataEntity.PmPlanCode,
                            dataEntity.PmPlanName,
                            dataEntity.PmCycleTime,
                            dataEntity.PmTimeUsage,
                            dataEntity.PmFirstDate,
                            dataEntity.PmContinueTimes,
                            dataEntity.PmPreAlarmDates,
                            dataEntity.PmPlanComment,
                            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);
        }
Exemplo n.º 2
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 == "EquMaintencePlan_Detail")
            {
                Equ_PmPlanInfo equinfo = new Equ_PmPlanInfo();
                equinfo.ID = RequstString("EquID");
                Equ_PmPlanInfo result = new Equ_PmPlanInfo();
                result = GetEquDetailObj(equinfo, result);
                context.Response.Write(jsc.Serialize(result));
            }
            else if (Action == "EquMaintencePlan_Add")
            {
                Equ_PmPlanInfo dataEntity = new Equ_PmPlanInfo();
                //dataEntity.ID = RequstString("ProcId");
                dataEntity.ProcessCode = RequstString("ProcessName");
                dataEntity.PmLevel     = RequstString("PmLevel");
                dataEntity.DeviceName  = RequstString("DeviceName");
                dataEntity.PmSpecName  = RequstString("PmSpecName");
                dataEntity.PmPlanCode  = RequstString("PmPlanCode");
                dataEntity.PmPlanName  = RequstString("PmPlanName");
                dataEntity.PmFirstDate = RequstString("PmFirstDate");

                if (RequstString("PmCycleTime").Length != 0)
                {
                    dataEntity.PmCycleTime = Convert.ToInt16(RequstString("PmCycleTime"));
                }
                else
                {
                    dataEntity.PmCycleTime = 0;
                }

                if (RequstString("PmTimeUsage").Length != 0)
                {
                    dataEntity.PmTimeUsage = Convert.ToInt16(RequstString("PmTimeUsage"));
                }
                else
                {
                    dataEntity.PmTimeUsage = 0;
                }

                if (RequstString("PmContinueTimes").Length != 0)
                {
                    dataEntity.PmContinueTimes = Convert.ToInt16(RequstString("PmContinueTimes"));
                }
                else
                {
                    dataEntity.PmContinueTimes = 0;
                }


                if (RequstString("PmPreAlarmDates").Length != 0)
                {
                    dataEntity.PmPreAlarmDates = Convert.ToInt16(RequstString("PmPreAlarmDates"));
                }
                else
                {
                    dataEntity.PmPreAlarmDates = 0;
                }

                //dataEntity.PmPreAlarmDates =Convert.ToInt16( RequstString("PmPreAlarmDates"));
                dataEntity.PmPlanComment = RequstString("PmPlanComment");
                ResultMsg_Equ_PmPlan result = new ResultMsg_Equ_PmPlan();
                result = addEquMaintencePlanDataInDB(dataEntity, result);
                context.Response.Write(jsc.Serialize(result));
            }
            else if (Action == "EquMaintencePlan_Edit")
            {
                Equ_PmPlanInfo dataEntity = new Equ_PmPlanInfo();
                dataEntity.ID          = RequstString("EquID");
                dataEntity.ProcessCode = RequstString("ProcessName");
                dataEntity.PmLevel     = RequstString("PmLevel");
                dataEntity.DeviceName  = RequstString("DeviceName");
                dataEntity.PmSpecName  = RequstString("PmSpecName");
                dataEntity.PmPlanCode  = RequstString("PmPlanCode");
                dataEntity.PmSpecName  = RequstString("PmSpecName");
                dataEntity.PmFirstDate = RequstString("PmFirstDate");
                dataEntity.PmPlanName  = RequstString("PmPlanName");
                if (RequstString("PmCycleTime").Length != 0)
                {
                    dataEntity.PmCycleTime = Convert.ToInt16(RequstString("PmCycleTime"));
                }
                else
                {
                    dataEntity.PmCycleTime = 0;
                }

                if (RequstString("PmTimeUsage").Length != 0)
                {
                    dataEntity.PmTimeUsage = Convert.ToInt16(RequstString("PmTimeUsage"));
                }
                else
                {
                    dataEntity.PmTimeUsage = 0;
                }

                if (RequstString("PmContinueTimes").Length != 0)
                {
                    dataEntity.PmContinueTimes = Convert.ToInt16(RequstString("PmContinueTimes"));
                }
                else
                {
                    dataEntity.PmContinueTimes = 0;
                }

                if (RequstString("PmPreAlarmDates").Length != 0)
                {
                    dataEntity.PmPreAlarmDates = Convert.ToInt16(RequstString("PmPreAlarmDates"));
                }
                else
                {
                    dataEntity.PmPreAlarmDates = 0;
                }
                dataEntity.PmPlanComment = RequstString("PmPlanComment");

                ResultMsg_Equ_PmPlan result = new ResultMsg_Equ_PmPlan();
                result = editEquMaintencePlanDataInDB(dataEntity, result);
                context.Response.Write(jsc.Serialize(result));
            }
        }