0
我在確定 書是可用還是不可用。如何檢查,然後如何設置驗證CONTROLE 我的編碼書的一頁問題創造庫管理系統中的一個網站是asp.net如何使用check availlable controle使用?
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 = "";
}
}