protected void btnAdd_Click(object sender, EventArgs e)
    {
        STreeFunctionData model = new STreeFunctionData();
        STreeFunctionBB treeFunctionBB = new STreeFunctionBB();
        try
        {
            //项目编号不允许重复
            string strWhere = "nodeId=" + this.NodeId.ToString() + " and functionNo='" + this.functionNo.Text + "'";
            if (treeFunctionBB.GetList(strWhere).Tables[0].Rows.Count > 0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"该功能编号已存在,请重新输入!\");", true);
                this.functionNo.Focus();
                return;
            }

            model.nodeId= this.NodeId;
            model.functionNo= this.functionNo.Text;
            model.functionNm= this.functionNm.Text;
            treeFunctionBB.AddRecord(model);
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            treeFunctionBB.Dispose();
        }

        this.ClientScript.RegisterStartupScript(this.GetType(), "CloseSubmit", "CloseSubmit()", true);
    }
Пример #2
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(STreeFunctionData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into STreeFunction(");
            strSql.Append("nodeId,functionNo,functionNm)");
            strSql.Append(" values (");
            strSql.Append("@nodeId,@functionNo,@functionNm)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@nodeId", SqlDbType.Int),
                    new SqlParameter("@functionNo", SqlDbType.NVarChar,50),
                    new SqlParameter("@functionNm", SqlDbType.NVarChar,50)
                };
            parameters[0].Value = model.nodeId;
            parameters[1].Value = model.functionNo;
            parameters[2].Value = model.functionNm;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
Пример #3
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        STreeFunctionData treeFunctionData = new STreeFunctionData();
        STreeFunctionBB treeFunctionBB = new STreeFunctionBB();
        try
        {
            //ɾ����ǰ�˵����й���
            treeFunctionBB.DeleteRecordByNode(this.NodeId);

            //��������
            foreach (DataListItem item in this.DataList1.Items)
            {
                CheckBox checkBox = (CheckBox)item.FindControl("typeNm");
                if (checkBox.Checked)
                {
                    HtmlInputHidden hid = (HtmlInputHidden)item.FindControl("typeNo");
                    string typeNo = hid.Value;

                    treeFunctionData.nodeId = this.NodeId;
                    treeFunctionData.functionNo = typeNo;
                    treeFunctionData.functionNm = checkBox.Text;
                    treeFunctionBB.AddRecord(treeFunctionData);
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            treeFunctionBB.Dispose();
        }

        this.ClientScript.RegisterStartupScript(this.GetType(), "Close", "window.close();", true);
    }
Пример #4
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(STreeFunctionData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update STreeFunction set ");
            strSql.Append("nodeId=@nodeId,");
            strSql.Append("functionNo=@functionNo,");
            strSql.Append("functionNm=@functionNm");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@nodeId", SqlDbType.Int),
                    new SqlParameter("@functionNo", SqlDbType.NVarChar,50),
                    new SqlParameter("@functionNm", SqlDbType.NVarChar,50)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.nodeId;
            parameters[2].Value = model.functionNo;
            parameters[3].Value = model.functionNm;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Пример #5
0
        /// <summary>
        /// �õ�һ��model
        /// </summary>
        /// <param name="id">����ֵ</param>
        /// <returns>model</returns>
        public STreeFunctionData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from STreeFunction");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            STreeFunctionData model = new STreeFunctionData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["nodeId"] != DBNull.Value)
                {
                    model.nodeId = Convert.ToInt32(row["nodeId"]);
                }
                if (row["functionNo"] != DBNull.Value)
                {
                    model.functionNo = Convert.ToString(row["functionNo"]);
                }
                if (row["functionNm"] != DBNull.Value)
                {
                    model.functionNm = Convert.ToString(row["functionNm"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Пример #6
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(STreeFunctionData model)
 {
     return this.treeFunctionDB.ModifyRecord(model);
 }
Пример #7
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(STreeFunctionData model)
 {
     return this.treeFunctionDB.AddRecord(model);
 }