2011-03-10 2 views
0

내가 CONTROLE 내 코딩을 검증 설정하는 방법은 다음 책을 확인 할 수 또는 사용할 수 없습니다 괜찮나입니다 확인하고 책의 한 페이지 문제에서 라이브러리 관리 시스템에서 하나 개의 웹 사이트를 만들asp.net check availlable controle use를 사용하는 방법?

public partial class Issueofbook : System.Web.UI.Page 
{ 
    public Int64 Sid; 

    protected void Page_Load(object sender, EventArgs e) 
    { 
     string Id; 
     Id = Request.QueryString.Get(0); 

     if (!(IsPostBack == true)) 
     { 
      if (Request.QueryString.Get(1) == "G") 
      { 
       Sid = Convert.ToInt64(Id); 
       if (PopulatedRecord(Sid) == false) 
       { 

       } 
      } 
     } 
    } 
    private Boolean PopulatedRecord(Int64 Id) 
    { 
     DataSet DS; 
     DS = new DataSet(); 
     SqlCommand cmd = new SqlCommand(); 
     SqlDataAdapter da = new SqlDataAdapter(); 
     SqlConnection Cnn = new SqlConnection(); 
     string connectionstring; 
     connectionstring = @"Datasource=DEVI\SQLEXPRESS;Intial             
        catalog=librarymanagement;Integrated Security=SSPI"; 
     Cnn.ConnectionString = connectionstring; 
     if (Cnn.State != ConnectionState.Open) 
      Cnn.Open(); 
     cmd.Connection = Cnn; 
     cmd.CommandType = CommandType.StoredProcedure; 
     cmd.CommandText = "usbinsertdatainto"; 
     cmd.Parameters.Clear(); 
     cmd.Parameters.AddWithValue("@bookno", txtno); 
     da.SelectCommand = cmd; 
     try 
     { 
      da.Fill(DS); 
     } 
     catch (Exception ex) 
     { 
      throw new ApplicationException(
       "!!! An Error Occured While Update Record In Dtl_SecurityCapital_Upload." + 
      ex.Message); 
      lblerror.Visible = true; 
      lblerror.Text = "!!! An Error Occured While " + ex.Message.ToString(); 
      return false; 
     } 
     if (DS.Tables[0].Rows.Count > 0) 
     { 
      txtno.Text = DS.Tables[0].Rows[0]["bookno"].ToString(); 
      txtstuno.Text = DS.Tables[0].Rows[0]["studentno"].ToString(); 
      RadioButton1.Text = DS.Tables[0].Rows[0]["copiesavaillable"].ToString(); 
      RadioButton2.Text = DS.Tables[0].Rows[0]["copiesavaillable"].ToString(); 
      txtdate.Text = DS.Tables[0].Rows[0]["IssueDate"].ToString(); 
      txtddate.Text = DS.Tables[0].Rows[0]["Duedate"].ToString(); 
     } 
     cmd.Dispose(); 
     Cnn.Close(); 
     Cnn.Dispose(); 
     return true; 
    } 

    protected void Btn_click(object sender, EventArgs e) 
{ 
    SqlCommand cmd = new SqlCommand(); 
    SqlConnection cnn = new SqlConnection(); 
    string connectionstring; 
    connectionstring = ConfigurationManager.ConnectionStrings["librarymanagementconnectionstring"].ConnectionStri 
     ng; 
    cnn.ConnectionString = connectionstring; 
    if (cnn.State != ConnectionState.Open) 
     cnn.Open(); 
    cmd.Connection = cnn; 
    cmd.CommandType = CommandType.StoredProcedure; 
    cmd.CommandText = "spupdatebookdetail"; 
    cmd.Parameters.Clear(); 
    cmd.Parameters.AddWithValue("@bookno", txtno.Text); 
    cmd.Parameters.AddWithValue("@studentno", txtstuno.Text); 
    cmd.Parameters.AddWithValue("@Issuedate", txtdate.Text); 
    cmd.Parameters.AddWithValue("@Duedate", txtddate.Text); 
    if(RadioButton1.Checked ==true) 
    { 
     cmd.Parameters.AddWithValue("@copiesavaillable", RadioButton1.Text); 
    } 
    if (RadioButton2.Checked==true) 
    { 
     cmd.Parameters.AddWithValue("@copiesavillable", RadioButton2.Text); 
    } 
    try 
    { 
     cmd.ExecuteNonQuery(); 
    } 
    catch (Exception ex) 
    { 
     throw new ApplicationException("!!! An error an occured while update the record In Dtl _captial upload." + ex.Message); 
     lblerror.Visible = true; 
     lblerror.Text = "!!! An error an occured while." + ex.Message.ToString(); 
    } 
    lblerror.Visible = true; 
    lblerror.Text = "Record update sucessfully"; 
    PopulatedRecord(Sid); 
} 

    protected void Button_click(object sender, EventArgs e) 
    { 
     Server.Transfer("useraccount.aspx"); 
    } 

    protected void Button2_Click(object sender, EventArgs e) 
    { 

     SqlConnection cnn = new SqlConnection(); 
     string constr = null; 
     SqlCommand cmd = new SqlCommand(); 
     constr = @"Data Source=DEVI\SQLEXPRESS; Initial Catalog =librarymanagement; Integrated Security=SSPI"; 
     cnn.ConnectionString = constr; 
     try 
     { 
      if (cnn.State != ConnectionState.Open) 
       cnn.Open(); 
     } 
     catch (Exception ex) 
     { 
      string str1 = null; 
      str1 = ex.ToString(); 
     } 
     cmd.Connection = cnn; 
     cmd.CommandType = CommandType.StoredProcedure; 
     cmd.CommandText = "uspInsertbookDatainto"; 
     cmd.Parameters.Clear(); 
     cmd.Parameters.AddWithValue("@bookno", txtno.Text); 
     cmd.Parameters.AddWithValue("@studentno", txtstuno.Text); 
     cmd.Parameters.AddWithValue("@Issuedate", txtdate.Text); 
     cmd.Parameters.AddWithValue("@Duedate", txtddate.Text); 
     if (RadioButton1.Checked == true) 
     { 
      cmd.Parameters.AddWithValue("@copiesavaillable", RadioButton1.Text); 
     } 
     if (RadioButton2.Checked == true) 
     { 
      cmd.Parameters.AddWithValue("@copiesavaillable", RadioButton2.Text); 
     } 
     try 
     { 
      cmd.ExecuteNonQuery(); 
     } 
     catch (Exception ex) 
     { 
      throw new ApplicationException("!!! An error an occured while Insert Record Dtl_SecurityCapital_Upload." + ex.Message); 
      lblerror.Visible = true; 
      lblerror.Text = "!!! An Error occured while ." + ex.Message.ToString(); 
     } 

     finally 
     { 
      cmd.Dispose(); 
     } 
     cnn.Close(); 
     lblerror.Text = "New Issue of record suceessfully!!"; 
     txtno.Text = ""; 
     txtstuno.Text = ""; 
     txtdate.Text = ""; 
     txtddate.Text = ""; 
    } 

} 

답변

0
되어있어

코드에는 이상하게 보이는 몇 가지 것이 있습니다. 예를 들어 (!(IsPostBack == true))은 아마도 (!IsPostBack) 일 것입니다. 또한, 당신은 아마 쿼리 문자열 매개 변수의 존재를 확인하고 이름을 Request.QueryString["name"] 으로 그것을 얻을이 대신

string id = Request.QueryString["id"]; 
if (id == null) 
{ 
    // do error handling here, no id specified; 
} 
else 
{ 
    // use id; 
} 

을 ... 더

당신은 무엇을 실제에 관해서는 구체적 할 수 있어야 문제는 달리 실행되지 않는 것입니까?