Ejemplo n.º 1
0
        /// <summary>
        /// 添加维保计划
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string Add(HttpContext context)
        {
            var jr = new JsonResultModel <int>()
            {
                IsSucceed   = false,
                Data        = 0,
                Msg         = "添加计划失败",
                RedirectUrl = string.Empty
            };
            MainTenanceSettingModel model = null;

            string msettingStr = context.Request.Params["mSetting"];
            string mcontentStr = context.Request.Params["mContent"];

            if (!string.IsNullOrEmpty(msettingStr))
            {
                var match = Regex.Match(msettingStr, "settingid=(\\d+?)&equID=(\\d+?)&mType=(\\d+?)&status=(\\d+?)&cycLength=(\\d+?)&cycUnit=(\\d+?)&isCyclic=(\\d+?)");
                model = new MainTenanceSettingModel()
                {
                    sID       = Convert.ToInt32(match.Groups[1].Value),
                    equID     = Convert.ToInt32(match.Groups[2].Value),
                    mType     = Convert.ToInt32(match.Groups[3].Value),
                    status    = match.Groups[4].Value == "0" ? false : true,
                    cycLength = Convert.ToInt32(match.Groups[5].Value),
                    cycUnit   = Convert.ToInt32(match.Groups[6].Value),
                    isCyclic  = match.Groups[7].Value == "0" ? false : true,
                    stratDate = DateTime.Now
                };
            }
            if (!string.IsNullOrEmpty(mcontentStr))
            {
                model.mcontentList = mcontentStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => new MainTenanceContentModel()
                {
                    settingID = model.sID, mtypeID = int.Parse(s)
                }).ToList();
            }

            if (msetting_bll.Add(model))
            {
                jr.IsSucceed = true;
                jr.Data      = 0;
                jr.Msg       = "添加计划成功";
            }

            return(JsonConvert.SerializeObject(jr));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MainTenanceSettingModel model)
        {
            List <string> cmdstrlist = new List <string>();
            StringBuilder strSql     = new StringBuilder();

            strSql.Append("update maintenancesetting set ");
            strSql.AppendFormat("equID={0},mType={1},cycLength={2},", model.equID, model.mType, model.cycLength);
            strSql.AppendFormat("cycUnit={0},isCyclic={1},stratDate='{2}',", model.cycUnit, model.isCyclic, DateTime.Now);
            strSql.AppendFormat("status={0},isDel={1} where sID={2}", model.status, 0, model.sID);
            cmdstrlist.Add(strSql.ToString());
            cmdstrlist.Add(string.Format("DELETE FROM maintenancecontent where settingID={0}", model.sID));
            foreach (var item in model.mcontentList)
            {
                cmdstrlist.Add(string.Format("insert into maintenancecontent (settingID,mtypeID) values({0},{1})", item.settingID, item.mtypeID));
            }

            return(MySQLHelper.ExecuteSqlByTran(cmdstrlist) > 0 ? true : false);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(MainTenanceSettingModel model)
        {
            List <string> cmdstrlist = new List <string>();

            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into maintenancesetting(");
            strSql.Append("equID,mType,cycLength,cycUnit,isCyclic,stratDate,status,isDel)");
            strSql.Append(" values (");
            strSql.AppendFormat("{0},{1},{2},{3},{4},'{5}',{6},{7});", model.equID, model.mType, model.cycLength, model.cycUnit, model.isCyclic, model.stratDate, model.status, model.isDel);
            strSql.Append(" select last_insert_id() as insertId");
            string maincmdstr = strSql.ToString();


            cmdstrlist.Add(string.Format("DELETE FROM maintenancecontent where settingID={0}", model.sID));

            foreach (var item in model.mcontentList)
            {
                cmdstrlist.Add(string.Format("insert into maintenancecontent (settingID,mtypeID) values([@],{0})", item.mtypeID));
            }

            return(MySQLHelper.ExecuteMasterslaveByTran(maincmdstr, cmdstrlist) > 0 ? true : false);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(MainTenanceSettingModel model)
 {
     return(msetting_dal.Update(model));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(MainTenanceSettingModel model)
 {
     return(msetting_dal.Add(model));
 }