/// <summary>
 /// 得到一个对象实体 子方法 从DataRow中
 /// </summary>
 public SCZM.Model.Base.base_ProcedureMachineNat DataRowToModel(DataRow row)
 {
     SCZM.Model.Base.base_ProcedureMachineNat model = new SCZM.Model.Base.base_ProcedureMachineNat();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["ProcedureId"] != null && row["ProcedureId"].ToString() != "")
         {
             model.ProcedureId = int.Parse(row["ProcedureId"].ToString());
         }
         if (row["MachineLevel10"] != null && row["MachineLevel10"].ToString() != "")
         {
             model.MachineLevel10 = decimal.Parse(row["MachineLevel10"].ToString());
         }
         if (row["MachineLevel20"] != null && row["MachineLevel20"].ToString() != "")
         {
             model.MachineLevel20 = decimal.Parse(row["MachineLevel20"].ToString());
         }
         if (row["MachineLevel30"] != null && row["MachineLevel30"].ToString() != "")
         {
             model.MachineLevel30 = decimal.Parse(row["MachineLevel30"].ToString());
         }
         if (row["MachineLevel40"] != null && row["MachineLevel40"].ToString() != "")
         {
             model.MachineLevel40 = decimal.Parse(row["MachineLevel40"].ToString());
         }
         if (row["MachineLevel50"] != null && row["MachineLevel50"].ToString() != "")
         {
             model.MachineLevel50 = decimal.Parse(row["MachineLevel50"].ToString());
         }
         if (row["NumType"] != null && row["NumType"].ToString() != "")
         {
             model.NumType = int.Parse(row["NumType"].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);
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(SCZM.Model.Base.base_ProcedureMachineNat model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update base_ProcedureMachineNat set ");
            strSql.Append("ProcedureId=@ProcedureId,");
            strSql.Append("MachineLevel10=@MachineLevel10,");
            strSql.Append("MachineLevel20=@MachineLevel20,");
            strSql.Append("MachineLevel30=@MachineLevel30,");
            strSql.Append("MachineLevel40=@MachineLevel40,");
            strSql.Append("MachineLevel50=@MachineLevel50,");
            strSql.Append("NumType=@NumType,");
            strSql.Append("FlagDel=@FlagDel,");
            strSql.Append("OperaId=@OperaId,");
            strSql.Append("OperaName=@OperaName,");
            strSql.Append("OperaTime=@OperaTime");
            strSql.Append(" where FlagDel=0 and ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProcedureId",    SqlDbType.Int,        4),
                new SqlParameter("@MachineLevel10", SqlDbType.Decimal,    9),
                new SqlParameter("@MachineLevel20", SqlDbType.Decimal,    9),
                new SqlParameter("@MachineLevel30", SqlDbType.Decimal,    9),
                new SqlParameter("@MachineLevel40", SqlDbType.Decimal,    9),
                new SqlParameter("@MachineLevel50", SqlDbType.Decimal,    9),
                new SqlParameter("@NumType",        SqlDbType.Int,        4),
                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("@ID",             SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.ProcedureId;
            parameters[1].Value  = model.MachineLevel10;
            parameters[2].Value  = model.MachineLevel20;
            parameters[3].Value  = model.MachineLevel30;
            parameters[4].Value  = model.MachineLevel40;
            parameters[5].Value  = model.MachineLevel50;
            parameters[6].Value  = model.NumType;
            parameters[7].Value  = model.FlagDel;
            parameters[8].Value  = model.OperaId;
            parameters[9].Value  = model.OperaName;
            parameters[10].Value = model.OperaTime;
            parameters[11].Value = model.ID;

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

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

            strSql.Append("insert into base_ProcedureMachineNat(");
            strSql.Append("ProcedureId,MachineLevel10,MachineLevel20,MachineLevel30,MachineLevel40,MachineLevel50,NumType,FlagDel,OperaId,OperaName,OperaTime)");
            strSql.Append(" values (");
            strSql.Append("@ProcedureId,@MachineLevel10,@MachineLevel20,@MachineLevel30,@MachineLevel40,@MachineLevel50,@NumType,@FlagDel,@OperaId,@OperaName,@OperaTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProcedureId",    SqlDbType.Int,       4),
                new SqlParameter("@MachineLevel10", SqlDbType.Decimal,   9),
                new SqlParameter("@MachineLevel20", SqlDbType.Decimal,   9),
                new SqlParameter("@MachineLevel30", SqlDbType.Decimal,   9),
                new SqlParameter("@MachineLevel40", SqlDbType.Decimal,   9),
                new SqlParameter("@MachineLevel50", SqlDbType.Decimal,   9),
                new SqlParameter("@NumType",        SqlDbType.Int,       4),
                new SqlParameter("@FlagDel",        SqlDbType.Int,       4),
                new SqlParameter("@OperaId",        SqlDbType.Int,       4),
                new SqlParameter("@OperaName",      SqlDbType.NVarChar, 10),
                new SqlParameter("@OperaTime",      SqlDbType.DateTime)
            };
            parameters[0].Value  = model.ProcedureId;
            parameters[1].Value  = model.MachineLevel10;
            parameters[2].Value  = model.MachineLevel20;
            parameters[3].Value  = model.MachineLevel30;
            parameters[4].Value  = model.MachineLevel40;
            parameters[5].Value  = model.MachineLevel50;
            parameters[6].Value  = model.NumType;
            parameters[7].Value  = model.FlagDel;
            parameters[8].Value  = model.OperaId;
            parameters[9].Value  = model.OperaName;
            parameters[10].Value = model.OperaTime;

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

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

            strSql.Append("select  top 1 ID,ProcedureId,MachineLevel10,MachineLevel20,MachineLevel30,MachineLevel40,MachineLevel50,NumType,FlagDel,OperaId,OperaName,OperaTime from base_ProcedureMachineNat ");
            strSql.Append(" where FlagDel=0 and ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #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 ProcedureId    = RequestHelper.GetString("ProcedureId");
            string MachineLevel10 = RequestHelper.GetString("MachineLevel10");
            string MachineLevel20 = RequestHelper.GetString("MachineLevel20");
            string MachineLevel30 = RequestHelper.GetString("MachineLevel30");
            string MachineLevel40 = RequestHelper.GetString("MachineLevel40");
            string MachineLevel50 = RequestHelper.GetString("MachineLevel50");
            string NumType        = RequestHelper.GetString("NumType");

            Model.System.sys_LoginUser loginUserModel      = BaseWeb.GetLoginInfo();
            SCZM.Model.Base.base_ProcedureMachineNat model = new SCZM.Model.Base.base_ProcedureMachineNat();
            SCZM.BLL.Base.base_ProcedureMachineNat   bll   = new SCZM.BLL.Base.base_ProcedureMachineNat();
            model.ID             = Utils.StrToInt(ID, 0);
            model.ProcedureId    = Utils.StrToInt(ProcedureId, 0);
            model.MachineLevel10 = Utils.StrToDecimal(MachineLevel10, 0);
            model.MachineLevel20 = Utils.StrToDecimal(MachineLevel20, 0);
            model.MachineLevel30 = Utils.StrToDecimal(MachineLevel30, 0);
            model.MachineLevel40 = Utils.StrToDecimal(MachineLevel40, 0);
            model.MachineLevel50 = Utils.StrToDecimal(MachineLevel50, 0);
            model.NumType        = Utils.StrToInt(NumType, 0);
            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;
            }
        }