예제 #1
0
 public int InsertType(TypeModel type)
 {
     SqlParameter[] param = { new SqlParameter("@TypeID", SqlDbType.Int), new SqlParameter("@Name", SqlDbType.VarChar, 20) };
     param[0].Value = type.TypeID;
     param[1].Value = type.Name;
     int result = SqlHelp.ExecuteNonQuery("prc_InsertType", CommandType.StoredProcedure, param);
     return result;
 }
예제 #2
0
 public List<TypeModel> GetCodeTable()
 {
     SqlDataReader dr = SqlHelp.ExecuteReader("prc_GetCodeTable", CommandType.StoredProcedure);
     List<TypeModel> list = new List<TypeModel>();
     while (dr.Read())
     {
         TypeModel type = new TypeModel();
         type.ID = Convert.ToInt32(dr[0]);
         type.TypeName = dr[1].ToString();
         list.Add(type);
     }
     dr.Close();
     return list;
 }
예제 #3
0
 public List<TypeModel> GetType(string typeCode)
 {
     SqlParameter param = new SqlParameter("@TableName", SqlDbType.VarChar, 10);
     param.Value = typeCode;
     SqlDataReader dr = SqlHelp.ExecuteReader("prc_GetType", CommandType.StoredProcedure,param);
     List<TypeModel> list = new List<TypeModel>();
     while (dr.Read())
     {
         TypeModel type = new TypeModel();
         type.ID = Convert.ToInt32(dr[0]);
         type.Name = dr[1].ToString();
         list.Add(type);
     }
     dr.Close();
     return list;
 }
예제 #4
0
 protected void Add_Click(object sender, EventArgs e)
 {
     TypeModel type = new TypeModel();
     type.TypeID = Convert.ToInt32(DDLType.SelectedValue);
     type.Name = txtName.Text.Trim();
     bool flag = bll.InsertType(type);
     if (flag)
     {
         Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('添加成功');</script>");
         CodeGridView.DataSource = bll.GetTypeByID(Convert.ToInt32(DDLType.SelectedValue));
         CodeGridView.DataBind();
     }
     else
     {
         Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('添加失败');</script>");
     }
     txtName.Text = "";
 }
예제 #5
0
 public bool InsertType(TypeModel type)
 {
     int result = dal.InsertType(type);
     return result == 0 ? false : true;
 }