Beispiel #1
0
        /// <summary>
        /// 插入一条明细记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Insert(clsDistrict model, out string errMsg)
        {
            errMsg = string.Empty;
            int rtn = 0;

            try
            {
                sb.Length = 0;
                sb.Append("INSERT INTO tDistrict(SysCode,StdCode,Name,ShortCut,DistrictIndex,CheckLevel,IsLocal,IsReadOnly,IsLock,Remark)");
                sb.Append(" VALUES(");
                sb.AppendFormat("'{0}',", model.SysCode);
                sb.AppendFormat("'{0}',", model.StdCode);
                sb.AppendFormat("'{0}',", model.Name);
                sb.AppendFormat("'{0}',", model.ShortCut);
                sb.AppendFormat("{0},", model.DistrictIndex);
                sb.AppendFormat("'{0}',", model.CheckLevel);
                sb.AppendFormat("{0},", model.IsLocal);
                sb.AppendFormat("{0},", model.IsReadOnly);
                sb.AppendFormat("{0},", model.IsLock);
                sb.AppendFormat("'{0}'", model.Remark);
                sb.Append(")");
                DataBase.ExecuteCommand(sb.ToString(), out errMsg);
                sb.Length = 0;

                rtn = 1;
            }
            catch (Exception e)
            {
                //Log.WriteLog("添加clsDistrict",e);
                errMsg = e.Message;
            }

            return(rtn);
        }
Beispiel #2
0
        /// <summary>
        /// 部分修改保存
        /// </summary>
        /// <param name="model">对象clsDistrict的一个实例参数</param>
        /// <returns></returns>
        public int UpdatePart(clsDistrict model, int lev, out string errMsg)
        {
            errMsg = string.Empty;
            int rtn = 0;

            try
            {
                sb.Length = 0;
                sb.Append("UPDATE tDistrict SET ");
                sb.Append(" StdCode='");
                sb.Append(model.StdCode);
                sb.Append("'");
                sb.Append(",Name='");
                sb.Append(model.Name);
                sb.Append("'");
                sb.Append(",ShortCut='");
                sb.Append(model.ShortCut);
                sb.Append("'");
                sb.Append(",DistrictIndex=");
                sb.Append(model.DistrictIndex);
                sb.Append(",CheckLevel='");
                sb.Append(model.CheckLevel);
                sb.Append("'");
                sb.Append(",IsLocal=");
                sb.Append(model.IsLocal);
                sb.Append(",IsReadOnly=");
                sb.Append(model.IsReadOnly);
                sb.Append(",IsLock=");
                sb.Append(model.IsLock);
                sb.Append(",Remark='");
                sb.Append(model.Remark);
                sb.Append("' WHERE SysCode='");
                sb.Append(model.SysCode);
                sb.Append("'");
                DataBase.ExecuteCommand(sb.ToString(), out errMsg);
                sb.Length = 0;

                //string updateSql="update tDistrict set "
                //+ "StdCode='" + model.StdCode + "',"
                //+ "Name='" + model.Name + "',"
                //+ "ShortCut='" + model.ShortCut + "',"
                //+ "DistrictIndex=" + model.DistrictIndex + ","
                //+ "CheckLevel='" + model.CheckLevel + "',"
                //+ "IsLocal=" + model.IsLocal + ","
                //+ "IsReadOnly=" + model.IsReadOnly + ","
                //+ "IsLock=" + model.IsLock + ","
                //+ "Remark='" + model.Remark + "'"
                //+ " where SysCode='" + model.SysCode + "' ";
                //DataBase.ExecuteCommand(updateSql,out sErrMsg);

                if (model.IsLocal)
                {
                    sb.Append("UPDATE tDistrict SET ");
                    sb.Append(" IsLocal=");
                    sb.Append(model.IsLocal);
                    sb.Append(" WHERE SysCode LIKE '");
                    sb.Append(model.SysCode);
                    sb.Append("%'");
                    DataBase.ExecuteCommand(sb.ToString(), out errMsg);
                    sb.Length = 0;
                    //string sql="update tDistrict set "
                    //    + "IsLocal=" + model.IsLocal
                    //    + " where SysCode like '" + model.SysCode + "%'";
                    //DataBase.ExecuteCommand(sql,out sErrMsg);
                }

                rtn = 1;
            }
            catch (Exception e)
            {
                //Log.WriteLog("更新clsDistrict",e);
                errMsg = e.Message;
            }

            return(rtn);
        }