/// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(SCZM.Model.Base.base_ProcessClass model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update base_ProcessClass set ");
            strSql.Append("ProcessClassName=@ProcessClassName,");
            strSql.Append("FlagDel=@FlagDel,");
            strSql.Append("OperaId=@OperaId,");
            strSql.Append("OperaName=@OperaName,");
            strSql.Append("OperaTime=@OperaTime,");
            strSql.Append("SortId=@SortId");
            strSql.Append(" where FlagDel=0 and ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProcessClassName", SqlDbType.NVarChar,  30),
                new SqlParameter("@FlagDel",          SqlDbType.Int,        4),
                new SqlParameter("@OperaId",          SqlDbType.Int,        4),
                new SqlParameter("@OperaName",        SqlDbType.NVarChar,  10),
                new SqlParameter("@OperaTime",        SqlDbType.DateTime),
                new SqlParameter("@SortId",           SqlDbType.Int,        4),
                new SqlParameter("@ID",               SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ProcessClassName;
            parameters[1].Value = model.FlagDel;
            parameters[2].Value = model.OperaId;
            parameters[3].Value = model.OperaName;
            parameters[4].Value = model.OperaTime;
            parameters[5].Value = model.SortId;
            parameters[6].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            return(rows);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SCZM.Model.Base.base_ProcessClass model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into base_ProcessClass(");
            strSql.Append("ProcessClassName,FlagDel,OperaId,OperaName,OperaTime,SortId)");
            strSql.Append(" values (");
            strSql.Append("@ProcessClassName,@FlagDel,@OperaId,@OperaName,@OperaTime,@SortId)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProcessClassName", SqlDbType.NVarChar,  30),
                new SqlParameter("@FlagDel",          SqlDbType.Int,        4),
                new SqlParameter("@OperaId",          SqlDbType.Int,        4),
                new SqlParameter("@OperaName",        SqlDbType.NVarChar,  10),
                new SqlParameter("@OperaTime",        SqlDbType.DateTime),
                new SqlParameter("@SortId",           SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ProcessClassName;
            parameters[1].Value = model.FlagDel;
            parameters[2].Value = model.OperaId;
            parameters[3].Value = model.OperaName;
            parameters[4].Value = model.OperaTime;
            parameters[5].Value = model.SortId;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SCZM.Model.Base.base_ProcessClass GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID.SortId,ProcessClassName,FlagDel,OperaId,OperaName,OperaTime from base_ProcessClass ");
            strSql.Append(" where FlagDel=0 and ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            SCZM.Model.Base.base_ProcessClass model = new SCZM.Model.Base.base_ProcessClass();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
 /// <summary>
 /// 得到一个对象实体 子方法 从DataRow中
 /// </summary>
 public SCZM.Model.Base.base_ProcessClass DataRowToModel(DataRow row)
 {
     SCZM.Model.Base.base_ProcessClass model = new SCZM.Model.Base.base_ProcessClass();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["SortId"] != null && row["SortId"].ToString() != "")
         {
             model.SortId = int.Parse(row["SortId"].ToString());
         }
         if (row["ProcessClassName"] != null)
         {
             model.ProcessClassName = row["ProcessClassName"].ToString();
         }
         if (row["FlagDel"] != null && row["FlagDel"].ToString() != "")
         {
             model.FlagDel = int.Parse(row["FlagDel"].ToString());
         }
         if (row["OperaId"] != null && row["OperaId"].ToString() != "")
         {
             model.OperaId = int.Parse(row["OperaId"].ToString());
         }
         if (row["OperaName"] != null)
         {
             model.OperaName = row["OperaName"].ToString();
         }
         if (row["OperaTime"] != null && row["OperaTime"].ToString() != "")
         {
             model.OperaTime = DateTime.Parse(row["OperaTime"].ToString());
         }
     }
     return(model);
 }
Esempio n. 5
0
        private void SaveData(HttpContext context, string btn)
        {
            if (btn != "btnSave")
            {
                context.Response.Write("{\"status\":\"0.2\",\"msg\":\"对不起,您没有操作权限!\"}");
                return;
            }
            string ID               = RequestHelper.GetString("ID");
            string SortId           = RequestHelper.GetString("SortId");
            string ProcessClassName = RequestHelper.GetString("ProcessClassName");

            Model.System.sys_LoginUser        loginUserModel = BaseWeb.GetLoginInfo();
            SCZM.Model.Base.base_ProcessClass model          = new SCZM.Model.Base.base_ProcessClass();
            SCZM.BLL.Base.base_ProcessClass   bll            = new SCZM.BLL.Base.base_ProcessClass();
            model.ID               = Utils.StrToInt(ID, 0);
            model.SortId           = Utils.StrToInt(SortId, 1);
            model.ProcessClassName = ProcessClassName;
            model.OperaId          = loginUserModel.ID;
            model.OperaName        = loginUserModel.PerName;
            model.OperaTime        = DateTime.Now;

            string operaMessage = "";
            string status       = "0";
            string operaAction  = "";
            string operaMemo    = "";

            try
            {
                if (ID == "")
                {
                    model.ID = bll.Add(model, out operaMessage);
                    if (model.ID > 0)
                    {
                        status      = "1";
                        operaAction = Enums.ActionEnum.Add.ToString();
                        operaMemo   = "新增工序大类:" + model.ID;
                    }
                }
                else
                {
                    if (bll.Update(model, out operaMessage))
                    {
                        status      = "1";
                        operaAction = Enums.ActionEnum.Edit.ToString();
                        operaMemo   = "修改工序大类:" + model.ID;
                    }
                }
                if (status == "1")
                {
                    //写入操作日志
                    BaseWeb.AddOpera(loginUserModel, int.Parse(RequestHelper.GetQueryString("MenuId")), operaAction, operaMemo);
                }
                context.Response.Write("{\"status\":\"" + status + "\",\"msg\":\"" + operaMessage + "\"}");
                return;
            }
            catch (Exception e)
            {
                context.Response.Write("{\"status\":\"0\",\"msg\":\"对不起,系统出错:" + Utils.HtmlEncode(e.Message) + "\"}");
                return;
            }
        }