protected void ImgDelete_Click(object sender, ImageClickEventArgs e) { try { string sql2 = "Delete deposit where id=@id"; SqlCommand cmd2 = new SqlCommand(); cmd2.Connection = cn; cmd2.CommandType = CommandType.Text; cmd2.CommandText = sql2; cmd2.Parameters.AddWithValue("id", LblId.Text); cn.Open(); cmd2.ExecuteNonQuery(); cmd2.Clone(); cn.Close(); depositchk(); } catch { } finally { cn.Close(); } }
} //end getDataSet; public int insertBookDetails(string sqlString) { int inserted; // SqlDataReader dbr; try { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = sqlString; cmd.Connection = this.GetConnection(); this.Open(); inserted = cmd.ExecuteNonQuery(); cmd.Clone(); this.Close(); //this.Open(); //SqlCommand cmd = new SqlCommand(sqlString, this.GetConnection()); //inserted = cmd.ExecuteNonQuery(); //dbr= cmd.ExecuteReader(); // inserted = 1; } finally { this.Close(); } return(inserted); }
public Bitmap DBgetimage(string sqlString) { //string sqlString = "select "+filedName+" from "+tableName+" where "+tableIDName+" = '"+tableIdValue+"'"; byte[] imagebytes = null; Bitmap bmpt = null; SqlConnection con = new SqlConnection(connectionString); con.Open(); try { SqlCommand com = new SqlCommand(sqlString, con); SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { if (dr.GetValue(0) == DBNull.Value) { return null; } imagebytes = (byte[])dr.GetValue(0); } dr.Close(); com.Clone(); MemoryStream ms = new MemoryStream(imagebytes); bmpt = new Bitmap(ms); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { con.Close(); } return bmpt; }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { try { if (TxtPassword.Text == "") { LblError.Visible = true; LblError.Text = "Please Enter the Pasword"; TxtPassword.Focus(); return; } cn.Open(); string sql = "UPDATE Staff SET First_Name=@First_Name, Last_Name=@Last_Name, Occupation=@Occupation, Designation=@Designation, Monthly_Salary=@Monthly_Salary,Email=@Email, Address=@Address, Country=@Country, City=@City, PostalCode=@PostalCode, Phone_Number=@Phone_Number, Password=@Password, SQ1=@SQ1, Answer1=@Answer1, SQ2=@SQ2, Answer2=@Answer2, SQ3=@SQ3, Answer3=@Answer3 where Staff_Id=@Mid"; SqlCommand cm = new SqlCommand(); cm.Connection = cn; cm.CommandType = CommandType.Text; cm.CommandText = sql; cm.Parameters.AddWithValue("@Mid", fn); cm.Parameters.Add("@First_Name", TxtFirstName.Text); cm.Parameters.Add("@Last_Name", TxtLastName.Text); cm.Parameters.Add("@Occupation", TxtOccupation.Text); cm.Parameters.Add("@Designation", TxtDesignation.Text); cm.Parameters.Add("@Monthly_Salary", TxtSalary.Text); cm.Parameters.Add("@Email", TxtEmail.Text); cm.Parameters.Add("@Address", TxtAddress.Text); cm.Parameters.Add("@Country", TxtCountry.Text); cm.Parameters.Add("@City", TxtCity.Text); cm.Parameters.Add("@PostalCode", TxtPostalCode.Text); cm.Parameters.Add("@Phone_Number", TxtPhoneNo.Text); cm.Parameters.Add("@Password", EncryptPasswrod(TxtPassword.Text)); cm.Parameters.Add("@SQ1", TxtQ1.Text); cm.Parameters.Add("@Answer1", TxtA1.Text); cm.Parameters.Add("@SQ2", TxtQ2.Text); cm.Parameters.Add("@Answer2", TxtA2.Text); cm.Parameters.Add("@SQ3", TxtQ3.Text); cm.Parameters.Add("@Answer3", TxtA3.Text); cm.ExecuteNonQuery(); cm.Clone(); cn.Close(); LblError.Visible = true; LblError.Text = "Information Updated Successfully"; getManagerinfo(); } catch { } finally { cn.Close(); } }
public static SqlCommand NewCmd_dbo_uf_Split() { if (_dbo_uf_Split_cmd != null) return _dbo_uf_Split_cmd.Clone(); _dbo_uf_Split_cmd = new SqlCommand("SELECT * FROM [dbo].[uf_Split](@text, @separator)"); _dbo_uf_Split_cmd.Parameters.Add(new SqlParameter("text", System.Data.SqlDbType.NVarChar, -1, ParameterDirection.Input, false, 0, 0, "text", DataRowVersion.Current, null)); _dbo_uf_Split_cmd.Parameters.Add(new SqlParameter("separator", System.Data.SqlDbType.NVarChar, -1, ParameterDirection.Input, false, 0, 0, "separator", DataRowVersion.Current, null)); return _dbo_uf_Split_cmd.Clone(); }
public static SqlCommand NewCmd_usp_Service_Init() { if (_usp_Service_Init != null) return _usp_Service_Init.Clone(); _usp_Service_Init = new SqlCommand("[usp].[Service_Init]"); _usp_Service_Init.CommandType = CommandType.StoredProcedure; _usp_Service_Init.Parameters.Add(new SqlParameter("RETURN_VALUE", System.Data.SqlDbType.Int, 0, ParameterDirection.ReturnValue, false, 0, 0, null, DataRowVersion.Current, null)); return _usp_Service_Init.Clone(); }
/// <summary> /// Purpose : To Delete All Category Data Into tblcategory. /// </summary> public void DeleteAllCategory() { cmd = new SqlCommand("sp_DeleteAllCategory", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); cmd.ExecuteNonQuery(); cmd.Clone(); }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { try { cn.Open(); string sql = "UPDATE Client SET First_Name=@First_Name, Last_Name=@Last_Name, Occupation=@Occupation, Designation=@Designation, Monthly_Salary=@Monthly_Salary,Email=@Email, Address=@Address, Country=@Country, City=@City, PostalCode=@PostalCode, Phone_Number=@Phone_Number,Status=@Status, SQ1=@SQ1, Answer1=@Answer1, SQ2=@SQ2, Answer2=@Answer2, SQ3=@SQ3, Answer3=@Answer3 where Client_Id=@cid"; SqlCommand cm = new SqlCommand(); cm.Connection = cn; cm.CommandType = CommandType.Text; cm.CommandText = sql; cm.Parameters.AddWithValue("@cid", LblClientId.Text); cm.Parameters.Add("@First_Name", TxtFirstName.Text); cm.Parameters.Add("@Last_Name", TxtLastName.Text); cm.Parameters.Add("@Occupation", TxtOccupation.Text); cm.Parameters.Add("@Designation", TxtDesignation.Text); cm.Parameters.Add("@Monthly_Salary", TxtSalary.Text); cm.Parameters.Add("@Email", TxtEmail.Text); cm.Parameters.Add("@Address", TxtAddress.Text); cm.Parameters.Add("@Country", TxtCountry.Text); cm.Parameters.Add("@City", TxtCity.Text); cm.Parameters.Add("@PostalCode", TxtPostalCode.Text); cm.Parameters.Add("@Phone_Number", TxtPhoneNo.Text); cm.Parameters.Add("@Status", TxtStatus.Text); cm.Parameters.Add("@SQ1", TxtQ1.Text); cm.Parameters.Add("@Answer1", TxtA1.Text); cm.Parameters.Add("@SQ2", TxtQ2.Text); cm.Parameters.Add("@Answer2", TxtA2.Text); cm.Parameters.Add("@SQ3", TxtQ3.Text); cm.Parameters.Add("@Answer3", TxtA3.Text); cm.ExecuteNonQuery(); cm.Clone(); cn.Close(); LblError.Visible = true; Session["label"] = "Information Updated Successfully"; LblError.Text = Session["label"].ToString(); } catch { } finally { cn.Close(); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string id = GridView1.DataKeys[e.RowIndex].Values[0].ToString(); string SqlStr = "delete from Sort where sortid='" + id + "'"; SqlConnection conn = sqlHelper.Connection();//新连接 SqlCommand comm = new SqlCommand(SqlStr, conn); conn.Open(); comm.ExecuteNonQuery(); comm.Clone(); conn.Close(); GridView1.EditIndex = -1; show(); }
public static SqlCommand NewCmd_usp_Service_Insert() { if (_usp_Service_Insert != null) return _usp_Service_Insert.Clone(); _usp_Service_Insert = new SqlCommand("[usp].[Service_Insert]"); _usp_Service_Insert.CommandType = CommandType.StoredProcedure; _usp_Service_Insert.Parameters.Add(new SqlParameter("RETURN_VALUE", System.Data.SqlDbType.Int, 0, ParameterDirection.ReturnValue, false, 0, 0, null, DataRowVersion.Current, null)); _usp_Service_Insert.Parameters.Add(new SqlParameter("ServiceTypeID", System.Data.SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "ServiceTypeID", DataRowVersion.Current, null)); _usp_Service_Insert.Parameters.Add(new SqlParameter("CreateTime", System.Data.SqlDbType.DateTime2, 8, ParameterDirection.Input, false, 27, 7, "CreateTime", DataRowVersion.Current, null)); _usp_Service_Insert.Parameters.Add(new SqlParameter("Name", System.Data.SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "Name", DataRowVersion.Current, null)); _usp_Service_Insert.Parameters.Add(new SqlParameter("Version", System.Data.SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "Version", DataRowVersion.Current, null)); _usp_Service_Insert.Parameters.Add(new SqlParameter("FilePath", System.Data.SqlDbType.NVarChar, 250, ParameterDirection.Input, false, 0, 0, "FilePath", DataRowVersion.Current, null)); _usp_Service_Insert.Parameters.Add(new SqlParameter("Description", System.Data.SqlDbType.NVarChar, -1, ParameterDirection.Input, false, 0, 0, "Description", DataRowVersion.Current, null)); return _usp_Service_Insert.Clone(); }
//更新 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { string id = GridView1.DataKeys[e.RowIndex].Values[0].ToString(); string sortname = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1")).Text; string SqlStr = "update Sort set sortname='"+sortname+"' where sortid='"+id+"'"; SqlConnection conn = sqlHelper.Connection();//新连接 SqlCommand comm = new SqlCommand(SqlStr, conn); conn.Open(); comm.ExecuteNonQuery(); comm.Clone(); conn.Close(); GridView1.EditIndex = -1; show(); }
public int cmd(string sqlcumle) { SqlConnection baglan = this.baglan(); SqlCommand sorgu = new SqlCommand(sqlcumle, baglan); int sonuc = 0; try { sonuc = sorgu.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message + "(" + sqlcumle + ")"); } sorgu.Dispose();//nesneyle işimiz bıttıgınde kullanılır sorgu.Clone();//Clone metodu ile hedef gösterilen dizinin aynısından tüm elemanları ile beraber kopyalanır. baglan.Dispose(); return (sonuc); }
protected void BtnSubmit_Click(object sender, ImageClickEventArgs e) { if (TxtPassword.Text != "") { if (TxtPassword.Text.Length < 3) { LblError.Visible = true; LblError.Text = "Please Enter atleast 3 character length Password"; TxtPassword.Focus(); return; } try { int i = 0; cn.Close(); string sql22 = "UPDATE Client SET Client_Check=@cc,Password=@pwd where Client_Id=@cid"; SqlCommand cmd22 = new SqlCommand(); cmd22.Connection = cn; cmd22.CommandType = CommandType.Text; cmd22.CommandText = sql22; cmd22.Parameters.AddWithValue("cid", fn); cmd22.Parameters.AddWithValue("cc", i); cmd22.Parameters.AddWithValue("pwd", EncryptPasswrod(TxtPassword.Text)); cn.Open(); cmd22.ExecuteNonQuery(); cmd22.Clone(); cn.Close(); Response.Redirect("~/Client/LoginClient.aspx", false); } catch { } } else { TxtPassword.Focus(); LblError.Visible = true; LblError.Text = "Please enter the password"; } }
public int insertIssueDetails(string sqlString) { int inserted; try { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = sqlString; cmd.Connection = this.GetConnection(); this.Open(); inserted = cmd.ExecuteNonQuery(); cmd.Clone(); this.Close(); } finally { this.Close(); } return(inserted); }
internal int updateReturned(string sqlString2) { int inserted; try { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = sqlString2; cmd.Connection = this.GetConnection(); this.Open(); inserted = cmd.ExecuteNonQuery(); cmd.Clone(); this.Close(); } finally { this.Close(); } return(inserted); }
protected void ImgUpdate0_Click(object sender, ImageClickEventArgs e) { try { cn.Close(); int i = 1; string sql2 = "UPDATE deposit SET Status=@cc where Id=@id"; SqlCommand cmd2 = new SqlCommand(); cmd2.Connection = cn; cmd2.CommandType = CommandType.Text; cmd2.CommandText = sql2; cmd2.Parameters.AddWithValue("id", LblId.Text); cmd2.Parameters.AddWithValue("cc", i); cn.Open(); cmd2.ExecuteNonQuery(); cmd2.Clone(); cn.Close(); updateclientAccout(); insertdata2(); } catch { } finally { cn.Close(); } }
void updateaccountamount() { try { string sql2 = "UPDATE Account SET Amount=@amount where Account_No=@No"; SqlCommand cmd2 = new SqlCommand(); cmd2.Connection = cn; cmd2.CommandType = CommandType.Text; cmd2.CommandText = sql2; cmd2.Parameters.AddWithValue("No", LblAccountNo.Text); cmd2.Parameters.AddWithValue("amount", sm); cn.Open(); cmd2.ExecuteNonQuery(); cmd2.Clone(); cn.Close(); depositchk(); } catch { } finally { cn.Close(); } }
void insertdata2() { try { getlatestamount(); DateTime statement_date = DateTime.Now; string title = "Deposite Cash"; double d = 0.0; cn.Open(); SqlCommand cm = new SqlCommand( "INSERT INTO Statement (Date,Title, Account, credit,debit , Total, Client_Id) VALUES(@Date,@Title, @Account, @credit,@debit, @Total, @Client_Id)", cn); cm.Parameters.Add("@Date", statement_date); cm.Parameters.Add("@Title", title); cm.Parameters.Add("@Account", LblAccountNo.Text); cm.Parameters.Add("@credit", TxtAmount.Text); cm.Parameters.Add("@debit", d); cm.Parameters.Add("@Total", latestamount); cm.Parameters.Add("@Client_Id", LblClientId.Text); cm.ExecuteNonQuery(); cm.Clone(); cn.Close(); } catch { } finally { cn.Close(); } }
/// <summary> /// Set leave configuration informations like casual, sick leaves and total working hours /// </summary> public static string SetLeaveConfigurationInformations(string ConnectionString, int TotalSickLeave, int TotalCasualLeave, int TotalWorkingHours) { var con = new SqlConnection(ConnectionString); try { using (var cmd = new SqlCommand(StoreProcedureSetLeavesAndWorkingHours, con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@TotalCasualLeave", SqlDbType.Int).Value = TotalCasualLeave; cmd.Parameters.Add("@TotalSickLeave", SqlDbType.Int).Value = TotalSickLeave; cmd.Parameters.Add("@TotalWorkingHours", SqlDbType.Int).Value = TotalWorkingHours; con.Open(); cmd.ExecuteNonQuery(); cmd.Clone(); } return "Success"; } catch (Exception) { return "Failed"; } }
private void button8_Click(object sender, EventArgs e) { byte[] imagebytes = null; try { string strConnection = "Data Source=DESKTOP-SK2RD82;Initial Catalog=TestDB;Integrated Security=True";//Initial catalog后面跟数据库的名字 SqlConnection conn = new SqlConnection(strConnection); conn.Open();//数据库链接打开 SqlCommand cmd = new SqlCommand(); cmd.CommandText = "select pic from sampling_record where sample_point ='1'"; cmd.Connection = conn; SqlDataReader bdr = cmd.ExecuteReader(); //SqlDataAdapter dbAdapter = new SqlDataAdapter(cmd); //DataSet ds = new DataSet(); while (bdr.Read()) { imagebytes = (byte[])(bdr.GetValue(0)); } bdr.Close(); cmd.Clone(); conn.Close();//关闭数据库连接 MemoryStream ms = new MemoryStream(imagebytes); Bitmap bmpt = new Bitmap(ms); pictureBox1.Image = bmpt; } catch (Exception) { MessageBox.Show("我操粗错了!\(≧▽≦)/"); } }
void insertfun() { try { cn.Close(); try { cn.Close(); cn.Open(); string sql = "Select Account_Number, Client_Id from ClientBill where Client_Id=@c_id and Account_Number=@AN"; SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; cmd.CommandText = sql; cmd.Parameters.AddWithValue("c_id", fn); cmd.Parameters.AddWithValue("AN", TxtAccountNo.Text); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { an1 = dr["Account_Number"].ToString(); cid1 = dr["Client_Id"].ToString(); } } dr.Close(); cn.Close(); if (an1 == TxtAccountNo.Text && cid1 == fn) { LblError.Visible = true; LblError.Text = "Company Info Already Exist"; return; } } catch { } finally { cn.Close(); } cn.Open(); SqlCommand cm = new SqlCommand( "INSERT INTO ClientBill (Transit_Id, Account_Number, Name, Client_Id) VALUES(@Transit_Id, @Account_Number, @Name, @Client_Id)", cn); cm.Parameters.Add("@Transit_Id", int.Parse(TxtTransitNo.Text)); cm.Parameters.Add("@Account_Number", int.Parse(TxtAccountNo.Text)); cm.Parameters.Add("@Name", TxtName.Text); cm.Parameters.Add("@Client_Id", fn); cm.ExecuteNonQuery(); cm.Clone(); cn.Close(); // Response.Write("Contact Added Successfully!"); LblError.Visible = true; LblError.Text = "Contact added Successfully"; Response.Redirect("BillList.aspx",false); // ClientBillList(); } catch (Exception ex) { Response.Write(ex.Message); } finally { cn.Close(); } }
void insertdata2() { try { getaccountno(); getlatestamount(); DateTime statement_date = DateTime.Now; string title = "Bill paid : " + LblCompanyName.Text; double d = 0.0; cn.Open(); SqlCommand cm = new SqlCommand( "INSERT INTO Statement (Date,Title, Account, credit,debit , Total, Client_Id) VALUES(@Date,@Title, @Account, @credit,@debit, @Total, @Client_Id)", cn); cm.Parameters.Add("@Date", statement_date); cm.Parameters.Add("@Title", title); cm.Parameters.Add("@Account", latestAcoountNo); cm.Parameters.Add("@credit", d); cm.Parameters.Add("@debit", txtamt); cm.Parameters.Add("@Total", latestamount); cm.Parameters.Add("@Client_Id", fn); cm.ExecuteNonQuery(); cm.Clone(); cn.Close(); TxtAmount.Text = ""; } catch { } finally { cn.Close(); } }
protected void ImgUpdate0_Click(object sender, ImageClickEventArgs e) { try { if (TxtAccountNo.Text != null && TxtRecipientName.Text !=null) { try { if (TxtAccountNo.Text.Length != 7) { LblError.Visible = true; LblError.Text = "Please enter 7 digits of Account Number "; return; } cn.Close(); cn.Open(); string sql = "Select Account_No from Account where Account_No=@AcNo"; SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; cmd.CommandText = sql; cmd.Parameters.AddWithValue("AcNo", TxtAccountNo.Text); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { an2 = dr["Account_No"].ToString(); } } dr.Close(); cn.Close(); if (an2 == TxtAccountNo.Text ) { LblError.Visible = true; LblError.Text = "The account Number is Valid"; // TxtAccountNo.Enabled = false; } else if (an2 != TxtAccountNo.Text) { LblError.Visible = true; LblError.Text = "The account Number does not exist"; return; } } catch { } finally { cn.Close(); } try { cn.Close(); cn.Open(); string sql = "Select Name, Account_No,Bank_Transit_No,Email, Client_Id from Recipient where Client_Id=@c_id and Bank_Transit_No=@BnkId and Account_No=@AcNo"; SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; cmd.CommandText = sql; cmd.Parameters.AddWithValue("c_id", fn); cmd.Parameters.AddWithValue("BnkId", TxtTransitNumber.Text); cmd.Parameters.AddWithValue("AcNo", TxtAccountNo.Text); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { TxtRecipientName.Text = dr["Name"].ToString(); an1 = dr["Account_No"].ToString(); bt = dr["Bank_Transit_No"].ToString(); TxtEmail.Text = dr["Email"].ToString(); cid1 = dr["Client_Id"].ToString(); } } dr.Close(); cn.Close(); if (an1 == TxtAccountNo.Text && cid1 == fn && bt == TxtTransitNumber.Text) { LblError.Visible = true; LblError.Text = "Recipient Already Exist Info Already Exist"; TxtTransitNumber.Text = bt; TxtAccountNo.Text = an1; return; } } catch { } finally { cn.Close(); } cn.Open(); SqlCommand cm = new SqlCommand( "INSERT INTO Recipient (Name,Account_No, Bank_Transit_No, Client_Id,Email) VALUES(@Name,@Account_No, @Bank_Transit_No, @Client_Id,@Email)", cn); cm.Parameters.Add("@Name", TxtRecipientName.Text); cm.Parameters.Add("@Account_No", TxtAccountNo.Text); cm.Parameters.Add("@Bank_Transit_No", TxtTransitNumber.Text); cm.Parameters.Add("@Client_Id", fn); cm.Parameters.Add("@Email", TxtEmail.Text); cm.ExecuteNonQuery(); cm.Clone(); cn.Close(); // Response.Write("Contact Added Successfully!"); LblError.Visible = true; LblError.Text = "Recipient added Successfully"; // Response.Redirect("BillList.aspx", false); // ClientBillList(); } else { LblError.Visible = true; LblError.Text = "Please Enter Mandatory Information"; } } catch (Exception ex) { Response.Write(ex.Message); } finally { cn.Close(); } }
void updateamount2() { try { getrecipientinfo(); cn.Close(); string sql2 = "UPDATE Account SET Amount=@cc where Account_No=@rac"; SqlCommand cmd2 = new SqlCommand(); cmd2.Connection = cn; cmd2.CommandType = CommandType.Text; cmd2.CommandText = sql2; cmd2.Parameters.AddWithValue("cc", amount2); cmd2.Parameters.AddWithValue("rac",r_ac); cn.Open(); cmd2.ExecuteNonQuery(); cmd2.Clone(); cn.Close(); LblError.Visible = true; LblError.Text = "Successfully Transfered The Amount"; try { getclientid(); getaccountno2(); cn.Close(); DateTime statement_date = DateTime.Now; string title = "Transfer From : " + latestAcoountNo; double d = 0.0; cn.Open(); SqlCommand cm = new SqlCommand( "INSERT INTO Statement (Date,Title, Account, credit,debit , Total, Client_Id) VALUES(@Date,@Title, @Account, @credit,@debit, @Total, @Client_Id)", cn); cm.Parameters.Add("@Date", statement_date); cm.Parameters.Add("@Title", title); cm.Parameters.Add("@Account", r_ac); cm.Parameters.Add("@credit", TxtAmount.Text); cm.Parameters.Add("@debit", d); cm.Parameters.Add("@Total", amount2); cm.Parameters.Add("@Client_Id", cid1); cm.ExecuteNonQuery(); cm.Clone(); cn.Close(); TxtAmount.Text = ""; LblError.Visible = true; LblError.Text = "Successfully Transfered The Amount"; } catch { } finally { cn.Close(); } } catch (Exception ex) { Response.Write(ex.Message); } finally { cn.Close(); } }
protected void BtnUpdate_Click(object sender, ImageClickEventArgs e) { try { if (TxtPassword.Text != "" && TxtUserName.Text != "") { string chk2 = Session["ccdd"].ToString(); LblError.Visible = true; LblError.Text = "information matching"; string sql2 = "UPDATE Admin SET Password=@pwd where Admin_Id=@cid"; SqlCommand cmd2 = new SqlCommand(); cmd2.Connection = cn; cmd2.CommandType = CommandType.Text; cmd2.CommandText = sql2; cmd2.Parameters.AddWithValue("cid", chk2); cmd2.Parameters.AddWithValue("pwd", EncryptPasswrod(TxtPassword.Text)); cn.Open(); cmd2.ExecuteNonQuery(); cmd2.Clone(); cn.Close(); LblAnswerError.Visible = true; LblAnswerError.Text = "Password successfully Updated please"; LblAnswerError.Text = "Mail send"; try { string emailfrom = "*****@*****.**"; string pwd = "inse6260"; string sb = "bank detail"; string ee = lbleml.Text; string pswd = TxtPassword.Text; string bd = "Admin User Name :" + TxtUserName.Text + " and Password is :" + pswd; MailMessage msg = new MailMessage(); msg.From = new MailAddress(emailfrom); msg.To.Add(ee); msg.Subject = sb; msg.Body = bd; SmtpClient sc = new SmtpClient("smtp.gmail.com"); sc.Port = 587; sc.Credentials = new NetworkCredential(emailfrom, pwd); sc.EnableSsl = true; sc.Send(msg); System.Threading.Thread.Sleep(5000); Response.Redirect("~/Admin/AdminLogin.aspx", false); } catch (Exception ex) { } } else { if (TxtPassword.Text == "") { Response.Write("Please enter passowrd"); TxtPassword.Focus(); } if (TxtUserName.Text == "") { Response.Write("Please enter Passport Number"); TxtUserName.Focus(); } return; } } catch { } finally { cn.Close(); } }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { try { try { cn.Open(); if (TxtPassportNo.Text != null) { int t1 = int.Parse(TxtPassportNo.Text); if (t1 <= 0) { LblError.Visible = true; LblError.Text = "Please enter Valid Passport Number"; TxtPassportNo.Focus(); return; } if (TxtPassportNo.Text.Length != 7) { LblMsg.Visible = true; LblMsg.Text = "Please Enter 7 digits passport number"; TxtPassportNo.Focus(); return; } if (TxtPassword.Text != "") { if (TxtPassword.Text.Length < 3) { LblError.Visible = true; LblError.Text = "Please Enter atleast 3 character length Password"; LblMsg.Visible = true; LblMsg.Text = "Please Enter atleast 3 character length Password"; TxtPassword.Focus(); LblMsg.Visible = true; return; } } string pas_Id = TxtPassportNo.Text; string sql = "Select PassportNo from Client where PassportNo=@pass_id"; SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; cmd.CommandText = sql; cmd.Parameters.AddWithValue("pass_id", pas_Id); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { pn1 = dr["PassportNo"].ToString(); } } dr.Close(); cn.Close(); if (pn1 == TxtPassportNo.Text) { LblError.Visible = true; LblError.Text = "Passport Number Already exist"; LblMsg.Visible = true; LblMsg.Text = "Passport Number Already exist"; TxtPassportNo.Focus(); return; } else { LblMsg.Visible = false; } } } catch { } finally { cn.Close(); } if (TxtPassportNo.Text != "" && TxtPassword.Text != "" && TxtEmail.Text != "" && TxtFirstName.Text != "" && TxtLastName.Text != "") { //int chars = TxtPassportNo.Text.Length; if (TxtPassportNo.Text.Length != 7) { LblError.Visible = true; LblMsg.Text = "Please Enter 7 digits passport number"; LblMsg.Visible = true; LblMsg.Text = "Please Enter 7 digits passport number"; TxtPassportNo.Focus(); LblMsg.Visible = true; return; } if (TxtA1.Text == "") { LblError.Visible = true; LblError.Text = "Please Enter Security Answers A1"; TxtA1.Focus(); return; } if (TxtA2.Text == "") { LblError.Visible = true; LblError.Text = "Please Enter Security Answers A2"; TxtA2.Focus(); return; } if (TxtA3.Text == "") { LblError.Visible = true; LblError.Text = "Please Enter Security Answers A3"; TxtA3.Focus(); return; } LblError.Visible = false; string dob = ddlDay.Text + "/" + ddlMonth.Text + "/" + ddlYear.Text; cn.Open(); DateTimeFormatInfo StartDate = new DateTimeFormatInfo(); StartDate.ShortDatePattern = "dd/MM/yyyy"; StartDate.DateSeparator = "/"; DateTime objDate = Convert.ToDateTime(dob, StartDate); int cnt = 0; SqlCommand cm = new SqlCommand( "INSERT INTO Client (First_Name, Last_Name, DOB, Occupation, Designation, Monthly_Salary,Email, Address, Country, City, PostalCode, Phone_Number, Status, Password, SQ1, Answer1, SQ2, Answer2, SQ3, Answer3, PassportNo, Client_Check) VALUES(@First_Name, @Last_Name, @DOB, @Occupation, @Designation, @Monthly_Salary,@Email, @Address, @Country, @City, @PostalCode, @Phone_Number, @Status, @Password, @SQ1, @Answer1, @SQ2, @Answer2, @SQ3, @Answer3, @PassportNo,@Client_Check)", cn); cm.Parameters.Add("@First_Name", TxtFirstName.Text); cm.Parameters.Add("@Last_Name", TxtLastName.Text); cm.Parameters.Add("@DOB", objDate); cm.Parameters.Add("@Occupation", TxtOccupation.Text); cm.Parameters.Add("@Designation", TxtDesignation.Text); cm.Parameters.Add("@Monthly_Salary", TxtSalary.Text); cm.Parameters.Add("@Email", TxtEmail.Text); cm.Parameters.Add("@Address", TxtAddress.Text); cm.Parameters.Add("@Country", TxtCountry.Text); cm.Parameters.Add("@City", TxtCity.Text); cm.Parameters.Add("@PostalCode", TxtPostalCode.Text); cm.Parameters.Add("@Phone_Number", TxtPhoneNo.Text); cm.Parameters.Add("@Status", TxtStatus.Text); cm.Parameters.Add("@Password", EncryptPasswrod(TxtPassword.Text)); cm.Parameters.Add("@SQ1", TxtQ1.Text); cm.Parameters.Add("@Answer1", TxtA1.Text); cm.Parameters.Add("@SQ2", TxtQ2.Text); cm.Parameters.Add("@Answer2", TxtA2.Text); cm.Parameters.Add("@SQ3", TxtQ3.Text); cm.Parameters.Add("@Answer3", TxtA3.Text); cm.Parameters.Add("@PassportNo", TxtPassportNo.Text); cm.Parameters.Add("@Client_Check", cnt); cm.ExecuteNonQuery(); cm.Clone(); //cmd.CommandText = "Insert INTO Client (First_Name, Last_Name, DOB, Occupation, Designation, Monthly_Salary, Address, Country, City, PostalCode, Phone_Number, Status, Password, SQ1, Answer1, SQ2, Answer2, SQ3, Answer3, PassportNo) VALUES ('" + TxtFirstName.Text + "','" + TxtLastName.Text + "','" + myDateTime + "','" + TxtOccupation.Text + "','" + TxtDesignation.Text + "','" + TxtSalary.Text + "','" + TxtAddress.Text + "','" + TxtCountry.Text + "','" + TxtCity.Text + "','" + TxtPostalCode.Text + "','" + TxtPhoneNo.Text + "','" + TxtStatus.Text + "','" + TxtPassword.Text + "','" + TxtQ1.Text + "','" + TxtA1.Text + "','" + TxtQ2.Text + "','" + TxtA2.Text + "','" + TxtQ3.Text + "','" + TxtA3.Text + "', '" + TxtPassportNo.Text + "')"; //cmd.ExecuteNonQuery(); //cmd.Clone(); cn.Close(); Response.Write("Contact Added Successfully!"); try { cn.Open(); string sql = "Select Client_Id from Client where PassportNo=@tp"; SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; cmd.CommandText = sql; cmd.Parameters.AddWithValue("tp", TxtPassportNo.Text); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { cd = dr["Client_Id"].ToString(); } } dr.Close(); cn.Close(); } catch { } finally { cn.Close(); insertaccount(); Session["cd"] = cd; Response.Redirect("~/Client/Register_Debit_Card.aspx", false); } { LblMsg.Visible = false; } } else { if (TxtPassword.Text == "") { LblError.Visible = true; LblError.Text = "Please enter passowrd"; TxtPassword.Focus(); } if (TxtPassword.Text != "") { if (TxtPassportNo.Text.Length != 3) { LblError.Visible = true; LblMsg.Text = "Please Enter atleast 3 character length Password"; LblMsg.Visible = true; LblMsg.Text = "Please Enter atleast 3 character length Password"; TxtPassword.Focus(); LblMsg.Visible = true; return; } } if (TxtPassportNo.Text == "") { LblError.Visible = true; LblError.Text = "Please enter Passport Number"; TxtPassportNo.Focus(); } if (TxtEmail.Text == "") { LblError.Visible = true; LblError.Text = "Please Enter Email"; TxtEmail.Focus(); } if (TxtFirstName.Text == "") { LblError.Visible = true; LblError.Text = "Please enter FirstName"; TxtFirstName.Focus(); } if (TxtLastName.Text == "") { LblError.Visible = true; LblError.Text = "Please enter Last Name"; TxtLastName.Focus(); } return; } } catch (Exception ex) { Response.Write(ex.Message); } finally { cn.Close(); } }
void insertbillamount() { try { if (TxtAmount.Text != "") { cn.Close(); cn.Open(); ///////////////////////// SqlCommand cm = new SqlCommand( "INSERT INTO Bill (Client_Id, Client_Bill_Id, Amount,date,Account_Type_Id) VALUES(@Client_Id, @Client_Bill_Id, @Amount,@date,@Account_Type_Id)", cn); cm.Parameters.Add("@Client_Id", LblClientId.Text); cm.Parameters.Add("@Client_Bill_Id", bill); cm.Parameters.Add("@Amount", TxtAmount.Text); cm.Parameters.Add("@date", dt); cm.Parameters.Add("@Account_Type_Id", DropDownList1.Text); cm.ExecuteNonQuery(); cm.Clone(); cn.Close(); LblError.Visible = true; updateamount(); Session["label"] = "Bill is Payed Successfully"; LblError.Text = Session["label"].ToString(); TxtAmount.Text = ""; } } catch (Exception ex) { Response.Write(ex.Message); } finally { cn.Close(); } }
/// <summary> /// ////////// to intert account type in account table w.r.t to client /// </summary> void insertaccount() { try { for (int loop = 1; loop <= 2; loop++) { cn.Close(); // getaccounttypeid(); getBanktransitNo(); getaccountnumber(); int cl_Id = int.Parse(cd); double amount = 0.0; //string sd = DDLAccountType.SelectedValue; // int ddl = int.Parse(st); cn.Open(); SqlCommand cm = new SqlCommand( "INSERT INTO Account (Account_Type_Id, Client_Id, Account_No, Bank_Transit_No, Amount, Opening_Date) VALUES(@Account_Type_Id, @Client_Id,@Account_No, @Bank_Transit_No, @Amount, @Opening_Date)", cn); cm.Parameters.Add("@Account_Type_Id", loop); cm.Parameters.Add("@Client_Id", cl_Id); cm.Parameters.Add("@Account_No", randomNumber); cm.Parameters.Add("@Bank_Transit_No", bank_Id); cm.Parameters.Add("@Amount", amount); cm.Parameters.Add("@Opening_Date", myDateTime2); cm.ExecuteNonQuery(); cm.Clone(); //cmd.CommandText = "Insert INTO Account (Account_Type_Id, Client_Id, Account_No, Bank_Transit_No, Amount, Opening_Date) VALUES ('" + id + "','" + cl_Id + "','" + randomNumber + "','" + bank_Id + "','" + amount + "','" + myDateTime + "')"; //cmd.ExecuteNonQuery(); //cmd.Clone(); Response.Write("Contact Added Successfully!"); } } catch (Exception ex) { Response.Write(ex.Message); } finally { cn.Close(); } }
void updateamount() { try { string sql2 = "UPDATE Account SET Amount=@cc where Client_Id=@cid and Account_Type_Id = @Account_Type_Id"; SqlCommand cmd2 = new SqlCommand(); cmd2.Connection = cn; cmd2.CommandType = CommandType.Text; cmd2.CommandText = sql2; cmd2.Parameters.AddWithValue("cc", amount); cmd2.Parameters.AddWithValue("cid", LblClientId.Text); cmd2.Parameters.AddWithValue("Account_Type_Id", DropDownList1.Text); cn.Open(); cmd2.ExecuteNonQuery(); cmd2.Clone(); cn.Close(); } catch (Exception ex) { Response.Write(ex.Message); } finally { cn.Close(); } }
void updatefun() { try { if (LblID.Text != null) { cn.Close(); string sql2 = "UPDATE Recipient SET Name=@nn, Account_No=@an,Email=@em where Recipient_Id=@R_id "; SqlCommand cmd2 = new SqlCommand(); cmd2.Connection = cn; cmd2.CommandType = CommandType.Text; cmd2.CommandText = sql2; cmd2.Parameters.AddWithValue("R_id", LblID.Text); cmd2.Parameters.AddWithValue("nn", TxtName.Text); cmd2.Parameters.AddWithValue("an", TxtAccountNo.Text); cmd2.Parameters.AddWithValue("em", TxtEmail.Text); cn.Open(); cmd2.ExecuteNonQuery(); cmd2.Clone(); cn.Close(); LblError.Visible = true; LblError.Text = "Recipient Account is Successfully updated"; recipientList(); } } catch (Exception ex) { Response.Write(ex.Message); } finally { cn.Close(); } }
void insertdebit() { try { cn.Close(); getBanktransitNo(); cn.Open(); int cl_id = int.Parse(LblClientId.Text); int b_id = int.Parse(band_id); string rn = Convert.ToString(randomNumber); ///////////////////////// Random randompin = new Random(); pin = randompin.Next(1000, 9999); SqlCommand cm = new SqlCommand( "INSERT INTO Debit_Card (Client_Id, Bank_Transit_No, Issue_Date, Expiery_Date, Debit_Card_No,PIN) VALUES(@Client_Id, @Bank_Transit_No, @Issue_Date, @Expiery_Date, @Debit_Card_No,@PIN)", cn); cm.Parameters.Add("@Client_Id", cl_id); cm.Parameters.Add("@Bank_Transit_No", band_id); cm.Parameters.Add("@Issue_Date", id); cm.Parameters.Add("@Expiery_Date", ed); cm.Parameters.Add("@Debit_Card_No", rn); cm.Parameters.Add("@PIN", pin); cm.ExecuteNonQuery(); cm.Clone(); cn.Close(); Response.Write("Contact Added Successfully!"); sndmail(); string idy = Convert.ToString(id); string ide = Convert.ToString(ed); int year = id.Year % 100; int month = id.Month % 100; string ii = Convert.ToString(month) + "/" + Convert.ToString(year); int e_year = ed.Year % 100; int e_month = ed.Month % 100; string ee = Convert.ToString(e_month) + "/" + Convert.ToString(e_year); LblDebitCard.Text = rn; LblExpieryDate.Text = ee; LblIssueDate.Text = ii; LblTransiId.Text = Convert.ToString(band_id); } catch (Exception ex) { Response.Write(ex.Message); } finally { cn.Close(); // Response.Redirect("~/Client/LoginClient.aspx"); } }
void insertfun() { try { cn.Close(); try { string sql2 = "UPDATE ClientBill SET Transit_Id=@Tid, Account_Number = @AN, Name=@NAME where Client_Id=@cid and Client_Bill_Id = @ClientBillId"; SqlCommand cmd2 = new SqlCommand(); cmd2.Connection = cn; cmd2.CommandType = CommandType.Text; cmd2.CommandText = sql2; cmd2.Parameters.AddWithValue("Tid", TxtTransitNo.Text); cmd2.Parameters.AddWithValue("AN", TxtAccountNo.Text); cmd2.Parameters.AddWithValue("Name", TxtName.Text); cmd2.Parameters.AddWithValue("cid",LblClientId.Text); cmd2.Parameters.AddWithValue("ClientBillId", Label13.Text); cn.Open(); cmd2.ExecuteNonQuery(); cmd2.Clone(); cn.Close(); LblError.Visible = true; LblError.Text = "Successfully Updated"; ClientBillList(); } catch (Exception ex) { Response.Write(ex.Message); LblError.Visible = true; LblError.Text = "This Account in not valid please enter a valid Account Number "; } finally { cn.Close(); } } catch (Exception ex) { Response.Write(ex.Message); } finally { cn.Close(); } }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { try { cn.Close(); cn.Open(); string sql = "SELECT UserName from Manager where UserName=@un "; SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; cmd.CommandText = sql; cmd.Parameters.AddWithValue("un", TxtUserName.Text); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { username = dr["UserName"].ToString(); } } dr.Close(); cn.Close(); if (username != null || username == "") { username = username.ToLower(); TxtUserName.Text = TxtUserName.Text.ToLower(); if (username == TxtUserName.Text) { LblError.Visible = true; LblError.Text = "The username '" + TxtUserName.Text + "' is Already Entered "; return; } else { LblError.Visible = false; } } else { LblError.Visible = false; } } catch (Exception ex) { Response.Write(ex.Message); } finally { cn.Close(); } try { if (TxtUserName.Text == "") { LblError.Visible = true; LblError.Text = "Please enter user name"; TxtUserName.Focus(); return; } if (TxtPassword.Text == "") { LblError.Visible = true; LblError.Text = "Please Password"; TxtPassword.Focus(); return; } if (TxtEmail.Text == "") { LblError.Visible = true; LblError.Text = "Please enter Email"; TxtEmail.Focus(); return; } if (TxtFirstName.Text == "") { LblError.Visible = true; LblError.Text = "Please enter First Name"; TxtFirstName.Focus(); return; } if (TxtLastName.Text == "") { LblError.Visible = true; LblError.Text = "Please enter Last Name"; TxtLastName.Focus(); return; } cn.Open(); string dob = ddlDay.Text + "/" + ddlMonth.Text + "/" + ddlYear.Text; DateTimeFormatInfo StartDate = new DateTimeFormatInfo(); StartDate.ShortDatePattern = "dd/MM/yyyy"; StartDate.DateSeparator = "/"; DateTime objDate = Convert.ToDateTime(dob, StartDate); DateTime jd = DateTime.Now; SqlCommand cm = new SqlCommand( "INSERT INTO Manager (First_Name, Last_Name, DOB, Occupation, Designation, Monthly_Salary, Email, Address, Country, City, PostalCode, Phone_Number, Status, Joining_Date, Password,Dept_Id, UserName, SQ1, Answer1, SQ2, Answer2, SQ3, Answer3) VALUES(@First_Name, @Last_Name, @DOB, @Occupation, @Designation, @Monthly_Salary, @Email, @Address, @Country, @City, @PostalCode, @Phone_Number, @Status, @Joining_Date, @Password,@Dept_Id, @User_Name, @SQ1, @Answer1, @SQ2, @Answer2, @SQ3, @Answer3)", cn); cm.Parameters.Add("@First_Name", TxtFirstName.Text); cm.Parameters.Add("@Last_Name", TxtLastName.Text); cm.Parameters.Add("@DOB", objDate); cm.Parameters.Add("@Occupation", TxtOccupation.Text); cm.Parameters.Add("@Designation", TxtDesignation.Text); cm.Parameters.Add("@Monthly_Salary", TxtSalary.Text); cm.Parameters.Add("@Email", TxtEmail.Text); cm.Parameters.Add("@Address", TxtAddress.Text); cm.Parameters.Add("@Country", TxtCountry.Text); cm.Parameters.Add("@City", TxtCity.Text); cm.Parameters.Add("@PostalCode", TxtPostalCode.Text); cm.Parameters.Add("@Phone_Number", TxtPhoneNo.Text); cm.Parameters.Add("@Status", TxtStatus.Text); cm.Parameters.Add("@Joining_Date", jd); cm.Parameters.Add("@Password", EncryptPasswrod(TxtPassword.Text)); cm.Parameters.Add("@Dept_Id", DDLAccountType.Text); cm.Parameters.Add("@User_Name", TxtUserName.Text); cm.Parameters.Add("@SQ1", TxtQ1.Text); cm.Parameters.Add("@Answer1", TxtA1.Text); cm.Parameters.Add("@SQ2", TxtQ2.Text); cm.Parameters.Add("@Answer2", TxtA2.Text); cm.Parameters.Add("@SQ3", TxtQ3.Text); cm.Parameters.Add("@Answer3", TxtA3.Text); cm.ExecuteNonQuery(); cm.Clone(); cn.Close(); LblError.Visible = true; LblError.Text = "An Email is sent to A Manager /n Account Added Successfully" ; try { string emailfrom = "*****@*****.**"; string pwd = "inse6260"; string sb = "Welcome to INSE 6260 Bank "; string bd = "Dear Manager! Toy Account Has been Created successfully /n : Your user name to Login is :" + TxtUserName.Text + " and Password is:" + TxtPassword.Text + " and Security Questions Answer is apple"; MailMessage msg = new MailMessage(); msg.From = new MailAddress(emailfrom); msg.To.Add(TxtEmail.Text); msg.Subject = sb; msg.Body = bd; SmtpClient sc = new SmtpClient("smtp.gmail.com"); sc.Port = 587; sc.Credentials = new NetworkCredential(emailfrom, pwd); sc.EnableSsl = true; sc.Send(msg); Response.Write("mail send successfully"); TxtFirstName.Text = ""; TxtLastName.Text = ""; TxtOccupation.Text = ""; TxtDesignation.Text = ""; TxtSalary.Text = ""; TxtEmail.Text = ""; TxtAddress.Text = ""; TxtCity.Text = ""; TxtPostalCode.Text = ""; TxtPhoneNo.Text = ""; TxtStatus.Text = ""; TxtUserName.Text = ""; TxtPassword.Text = ""; TxtA1.Text = ""; TxtA2.Text = ""; TxtA3.Text = ""; Response.Redirect("~/Admin/AdminMenu.aspx", false); } catch (Exception ex) { } } catch { } }