protected void btn_modify_Click(object sender, EventArgs e)
        {
            bool b;

            if (Context.Request["ddTypeId"] != null)
            {
                datadicType.DdTypeId   = Convert.ToInt32(Context.Request["ddTypeId"]);
                datadicType.DdTypeName = tb_ddTypeName.Text;
                datadicType.DdTypeDesc = tb_ddTypeDesc.Text;
                b = datadicTypeDao.datadicTypeUpdate(datadicType);
                if (b)
                {
                    Session["flag"] = "modifySuccess";
                    Response.Redirect("datadicTypeList.aspx");
                }
            }
            else
            {
                datadicType            = new DatadicType();
                datadicType.DdTypeName = tb_ddTypeName.Text;
                datadicType.DdTypeDesc = tb_ddTypeDesc.Text;
                b = datadicTypeDao.datadicTypeAdd(datadicType);
                if (b)
                {
                    Session["flag"] = "addSuccess";
                    Response.Redirect("datadicTypeList.aspx");
                }
            }
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            DatadicType datadicType = datadicTypeDao.findById(Convert.ToInt32(txtddTyId.Text));
            bool        b           = datadicTypeDao.datadicTypeDelete(datadicType);

            if (b)
            {
                Session["flag"] = "delSuccess";
                Response.Redirect("datadicTypeList.aspx");
            }
            else
            {
                Session["flag"] = "delFailure";
                Response.Redirect("datadicTypeList.aspx");
            };
        }
Beispiel #3
0
        //删除书籍类别信息,传入一个DatadicType对象,根据传入对象的ddTypeId进行删除查询,更新成功返回true,否则返回false
        public bool datadicTypeDelete(DatadicType datadicType)
        {
            sqlCon = dbUtil.getCon();
            string     cmdText = "delete from t_datadicType where ddTypeId=" + datadicType.DdTypeId;
            SqlCommand sqlcom  = new SqlCommand(cmdText, sqlCon);
            int        n       = sqlcom.ExecuteNonQuery();//返回受影响的行数

            if (n == 1)
            {
                dbUtil.close(sqlCon);
                return(true);
            }
            else
            {
                dbUtil.close(sqlCon);
                return(false);
            }
        }
Beispiel #4
0
        //更新书籍类别信息,传入一个DatadicType对象,根据传入对象的ddTypeId进行更新查询,更新成功返回true,否则返回false
        public bool datadicTypeUpdate(DatadicType datadicType)
        {
            sqlCon = dbUtil.getCon();
            string     cmdText = "update t_datadicType set ddTypeName='" + datadicType.DdTypeName + "',   ddTypeDesc='" + datadicType.DdTypeDesc + "' where ddTypeId=" + datadicType.DdTypeId;
            SqlCommand sqlcom  = new SqlCommand(cmdText, sqlCon);
            int        n       = sqlcom.ExecuteNonQuery();//返回受影响的行数

            if (n == 1)
            {
                dbUtil.close(sqlCon);
                return(true);
            }
            else
            {
                dbUtil.close(sqlCon);
                return(false);
            }
        }
Beispiel #5
0
        //插入一个传进来的不含ddTypeId属性的ddType对象,插入成功返回true,否则返回false
        public bool datadicTypeAdd(DatadicType datadicType)
        {
            sqlCon = dbUtil.getCon();
            string     cmdText = "insert into t_datadicType (ddTypeName, ddTypeDesc) values('" + datadicType.DdTypeName + "','" + datadicType.DdTypeDesc + "')";
            SqlCommand sqlcom  = new SqlCommand(cmdText, sqlCon);
            int        n       = sqlcom.ExecuteNonQuery();//返回受影响的行数

            if (n == 1)
            {
                dbUtil.close(sqlCon);
                return(true);
            }
            else
            {
                dbUtil.close(sqlCon);
                return(false);
            }
        }
Beispiel #6
0
        //根据主键查询某一个DatadicType
        public DatadicType findById(int ddTypeId)
        {
            sqlCon = dbUtil.getCon();
            DatadicType   resultDatadicType = null;
            string        cmdText           = "select * from t_datadicType where ddTypeId=" + ddTypeId; //查询用户字符串
            SqlCommand    sqlCmd            = new SqlCommand(cmdText, sqlCon);                          //查询对象
            SqlDataReader sqlDr             = sqlCmd.ExecuteReader();                                   //创建逐行数据读取器对象

            if (sqlDr.Read())
            {
                resultDatadicType            = new DatadicType();
                resultDatadicType.DdTypeId   = (int)sqlDr["ddTypeId"];
                resultDatadicType.DdTypeName = (string)sqlDr["ddTypeName"];
                resultDatadicType.DdTypeDesc = (string)sqlDr["ddTypeDesc"];
            }
            sqlDr.Close();
            dbUtil.close(sqlCon);
            return(resultDatadicType);
        }
Beispiel #7
0
        //根据ddTypeName判断是否已经存在,返回true表示已经存在该类别,否则不存在
        public bool existDatadicType(DatadicType datadicType)
        {
            sqlCon = dbUtil.getCon();
            string        cmdText = "select * from t_datadicType where ddTypeName='" + datadicType.DdTypeName + "'";
            SqlCommand    sqlCmd  = new SqlCommand(cmdText, sqlCon); //查询对象
            SqlDataReader sqlDr   = sqlCmd.ExecuteReader();          //创建逐行数据读取器对象

            if (sqlDr.Read())
            {
                sqlDr.Close();
                dbUtil.close(sqlCon);
                return(true);
            }
            else
            {
                sqlDr.Close();
                dbUtil.close(sqlCon);
                return(false);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int ddTypeId = Convert.ToInt32(Context.Request["ddTypeId"]);

            //根据datadicTypeList页面传过来的datadicTypeId从数据库中获取datadicType对象
            datadicType = datadicTypeDao.findById(ddTypeId);
            if (!IsPostBack)
            {
                if (Context.Request["ddTypeId"] == null)
                {
                    tb_ddTypeDesc.Text = "";
                    tb_ddTypeName.Text = "";
                }
                else
                {
                    tb_ddTypeName.Text = datadicType.DdTypeName;
                    tb_ddTypeDesc.Text = datadicType.DdTypeDesc;
                }
            }
        }
 protected void listDatadicType_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     //点击删除按钮,删除对应一条的信息
     if (e.CommandName == "delete")
     {
         int         ddTypeId    = Convert.ToInt32(e.CommandArgument.ToString());
         DatadicType datadicType = new DatadicType();
         datadicType.DdTypeId = ddTypeId;
         bool b = datadicTypeDao.datadicTypeDelete(datadicType);
         if (b)
         {
             Response.Redirect("datadicTypeList.aspx");
         }
     }
     //点击修改,跳转到datadicTypeModify,并且将ddTypeId作为参数传过去
     else if (e.CommandName == "modify")
     {
         string url;
         url = "datadicTypeSave.aspx?ddTypeId=" + e.CommandArgument;
         Response.Redirect(url);
     }
 }