Пример #1
0
        protected void btnadd_Click(object sender, EventArgs e)
        {
            string name   = "^[a-zA-Z0-9\u4e00-\u9fa5-]{1,}$";//字母数字汉字-
            Regex  rxname = new Regex(name);

            modelPartType = bllPartType.GetModel(Request.QueryString["ID"].ToString());
            if (PartTypeName.Text.Trim() == "")
            {
                RadAjaxManager1.Alert("配件类别名称不能为空!");
                return;
            }
            if (!rxname.IsMatch(PartTypeName.Text.Trim()) && PartTypeName.Text.Trim() != "")
            {
                RadAjaxManager1.Alert("类别名称不能输入特殊字符!");
                return;
            }
            if (bllPartType.GetList("  PartTypeName='" + PartTypeName.Text + "'  ").Tables[0].Rows.Count != 0 && PartTypeName.Text.Trim() != modelPartType.PartTypeName)
            {
                RadAjaxManager1.Alert("该类别名称已存在!");
                return;
            }
            modelPartType.PartTypeName = PartTypeName.Text;
            bllPartType.Update(modelPartType);
            RadAjaxManager1.Alert("修改成功!");

            ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>CloseAndRebind();</script>");
        }
Пример #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (UsersInfo.UserID == "" || UsersInfo.UserRole != "维修中心管理员")
     {
         UsersInfo.UserID   = "";
         UsersInfo.UserName = "";
         UsersInfo.UserRole = "";
         Response.Redirect("~/BackLogin.aspx");
         return;
     }
     btnback.Attributes["onclick"] = "GetClose();return false;";
     if (!IsPostBack)
     {
         if (Request.QueryString["ID"] == null)
         {
             RadAjaxManager1.Alert("请选择一条数据!");
             Response.Write("<script>window.location.href='PartsType.aspx'</script>");
             return;
         }
         modelparttype = bllPartType.GetModel(Request.QueryString["ID"].ToString());
         if (modelparttype == null)
         {
             RadAjaxManager1.Alert("请选择一条数据!");
             ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>CloseAndRebind();</script>");
             return;
         }
         PartTypeName.Text = modelparttype.PartTypeName;
     }
 }
Пример #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.PartType DataRowToModel(DataRow row)
 {
     Maticsoft.Model.PartType model = new Maticsoft.Model.PartType();
     if (row != null)
     {
         if (row["PartTypeID"] != null)
         {
             model.PartTypeID = row["PartTypeID"].ToString();
         }
         if (row["PartTypeName"] != null)
         {
             model.PartTypeName = row["PartTypeName"].ToString();
         }
         if (row["PartTypeAddTime"] != null && row["PartTypeAddTime"].ToString() != "")
         {
             model.PartTypeAddTime = DateTime.Parse(row["PartTypeAddTime"].ToString());
         }
         if (row["PartTypePicture"] != null)
         {
             model.PartTypePicture = row["PartTypePicture"].ToString();
         }
         if (row["PartTypeIntroduction"] != null)
         {
             model.PartTypeIntroduction = row["PartTypeIntroduction"].ToString();
         }
         if (row["HHH1"] != null)
         {
             model.HHH1 = row["HHH1"].ToString();
         }
         if (row["HHH2"] != null)
         {
             model.HHH2 = row["HHH2"].ToString();
         }
         if (row["HHH3"] != null)
         {
             model.HHH3 = row["HHH3"].ToString();
         }
         if (row["HHH4"] != null)
         {
             model.HHH4 = row["HHH4"].ToString();
         }
         if (row["HHH5"] != null)
         {
             model.HHH5 = row["HHH5"].ToString();
         }
     }
     return(model);
 }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.PartType GetModel(string PartTypeID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" PartTypeID,PartTypeName,PartTypeAddTime,PartTypePicture,PartTypeIntroduction,HHH1,HHH2,HHH3,HHH4,HHH5 ");
            strSql.Append(" from PartType ");
            strSql.Append(" where PartTypeID='" + PartTypeID + "' ");
            Maticsoft.Model.PartType model = new Maticsoft.Model.PartType();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.PartType model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.PartTypeID != null)
            {
                strSql1.Append("PartTypeID,");
                strSql2.Append("'" + model.PartTypeID + "',");
            }
            if (model.PartTypeName != null)
            {
                strSql1.Append("PartTypeName,");
                strSql2.Append("'" + model.PartTypeName + "',");
            }
            if (model.PartTypeAddTime != null)
            {
                strSql1.Append("PartTypeAddTime,");
                strSql2.Append("'" + model.PartTypeAddTime + "',");
            }
            if (model.PartTypePicture != null)
            {
                strSql1.Append("PartTypePicture,");
                strSql2.Append("'" + model.PartTypePicture + "',");
            }
            if (model.PartTypeIntroduction != null)
            {
                strSql1.Append("PartTypeIntroduction,");
                strSql2.Append("'" + model.PartTypeIntroduction + "',");
            }
            if (model.HHH1 != null)
            {
                strSql1.Append("HHH1,");
                strSql2.Append("'" + model.HHH1 + "',");
            }
            if (model.HHH2 != null)
            {
                strSql1.Append("HHH2,");
                strSql2.Append("'" + model.HHH2 + "',");
            }
            if (model.HHH3 != null)
            {
                strSql1.Append("HHH3,");
                strSql2.Append("'" + model.HHH3 + "',");
            }
            if (model.HHH4 != null)
            {
                strSql1.Append("HHH4,");
                strSql2.Append("'" + model.HHH4 + "',");
            }
            if (model.HHH5 != null)
            {
                strSql1.Append("HHH5,");
                strSql2.Append("'" + model.HHH5 + "',");
            }
            strSql.Append("insert into PartType(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.PartType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update PartType set ");
            if (model.PartTypeName != null)
            {
                strSql.Append("PartTypeName='" + model.PartTypeName + "',");
            }
            else
            {
                strSql.Append("PartTypeName= null ,");
            }
            if (model.PartTypeAddTime != null)
            {
                strSql.Append("PartTypeAddTime='" + model.PartTypeAddTime + "',");
            }
            else
            {
                strSql.Append("PartTypeAddTime= null ,");
            }
            if (model.PartTypePicture != null)
            {
                strSql.Append("PartTypePicture='" + model.PartTypePicture + "',");
            }
            else
            {
                strSql.Append("PartTypePicture= null ,");
            }
            if (model.PartTypeIntroduction != null)
            {
                strSql.Append("PartTypeIntroduction='" + model.PartTypeIntroduction + "',");
            }
            else
            {
                strSql.Append("PartTypeIntroduction= null ,");
            }
            if (model.HHH1 != null)
            {
                strSql.Append("HHH1='" + model.HHH1 + "',");
            }
            else
            {
                strSql.Append("HHH1= null ,");
            }
            if (model.HHH2 != null)
            {
                strSql.Append("HHH2='" + model.HHH2 + "',");
            }
            else
            {
                strSql.Append("HHH2= null ,");
            }
            if (model.HHH3 != null)
            {
                strSql.Append("HHH3='" + model.HHH3 + "',");
            }
            else
            {
                strSql.Append("HHH3= null ,");
            }
            if (model.HHH4 != null)
            {
                strSql.Append("HHH4='" + model.HHH4 + "',");
            }
            else
            {
                strSql.Append("HHH4= null ,");
            }
            if (model.HHH5 != null)
            {
                strSql.Append("HHH5='" + model.HHH5 + "',");
            }
            else
            {
                strSql.Append("HHH5= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where PartTypeID='" + model.PartTypeID + "' ");
            int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }