private string getUserName() { SqlConnect spam = new SqlConnect(); bool admin = spam.IsAdminById(); if (admin) { UserName = "******"; } else { UserName = "******"; } return(userName); }
private void GetData() { SqlConnect sql = new SqlConnect(); String sorgu = "select * from Users Order By Name"; using (SqlCommand komut = new SqlCommand(sorgu, sql.connection())) { SqlDataAdapter adapter = new SqlDataAdapter(komut); DataSet ds = new DataSet(); adapter.Fill(ds); UserTable.DataSource = ds; UserTable.DataBind(); } sql.disconnection(); }
public UserPower Login(UserPower u) { SqlConnect conn = new SqlConnect(); string sql = "select * from dbo.JCI_newEmp emp where 1=1 and emp.empId='" + u.UserId + "' and emp.deptNum='" + u.UserDept + "' and emp.psw='" + u.Psw + "'"; DataTable dt = conn.ExcuteSelect(sql); if (dt.Rows.Count > 0) { u.Power = GetPower(dt.Rows[0]["power"].ToString()); u.UserDeptName = dt.Rows[0]["deptName"].ToString(); u.UserDept = dt.Rows[0]["deptNum"].ToString(); return(u); } return(null); }
//Save to gara private void btnSaveGara_Click(object sender, EventArgs e) { if (check = false) { if (CheckIn_Up()) { string sqlINSERT = "INSERT INTO dbo.THONGTINXE( BienSoXe , HangXe ,DoiXe ,SoKhung , SoMay , SoKM) VALUES ( '" + txtBS.Text + "' ,N'" + txtHangXe.Text + "' ,N'" + txtDX.Text + "' ,N'" + txtSoKhung.Text + "' , N'" + txtSoMay.Text + "' , N'" + txtSoKM.Text + "' )"; SqlConnect connect = new SqlConnect(); connect.OpenConnect(); SqlCommand cmd = new SqlCommand(sqlINSERT, connect.Conn); cmd.ExecuteNonQuery(); LoadXe(); connect.CloseConnect(); lockTxtGara(); } else { MessageBox.Show("Bạn phải điền đầy đủ thông tin!"); } } else { if (CheckIn_Up()) { string sqlEDIT = "UPDATE THONGTINXE set DoiXe = '" + txtDX.Text + "' , SoKhung = '" + txtSoKhung.Text + "', SoMay = '" + txtSoMay.Text + "', SoKM = '" + txtSoKM.Text + "' where HangXe = '" + txtHangXe.Text + "' AND BienSoXe = '" + txtBS.Text + "'"; SqlConnect connect = new SqlConnect(); connect.OpenConnect(); SqlCommand cmd = new SqlCommand(sqlEDIT, connect.Conn); cmd.ExecuteNonQuery(); LoadXe(); connect.CloseConnect(); lockTxtGara(); } else { MessageBox.Show("Bạn cần chọn xe cần sửa!"); resetEnableBtn("done"); lockTxtGara(); } } resetTxtGara(); resetEnableBtn("done"); }
private void Spend_OnClick(object sender, RoutedEventArgs e) { Spend.IsEnabled = false; // Get amount of expense var expense = GetMoneyInput(); if (expense <= 0) { Spend.IsEnabled = true; return; } // Get category string category; if (string.IsNullOrWhiteSpace(Category.Text)) { MessageBox.Show(@"You didn't choose category"); Spend.IsEnabled = true; return; } else { category = Category.Text; } // Get current total _current = _current - expense; // Update the expense list var expenseInput = new SqlConnect.Bank(expense, DateTime.Now, category); SqlConnect.InsertMoney("expense", _userId, expense, category); _expense.Add(expenseInput); _observableDataBanks.Add(expenseInput); // Update Total list and database var currentTotal = new SqlConnect.Bank(_current, DateTime.Now); SqlConnect.InsertMoney("total", _userId, _current); _total.Add(currentTotal); // Show current total CurrentMoney.Text = _current.ToString("C"); //MessageBox.Show(@"You successfully added an expense to your bank"); Spend.IsEnabled = true; }
private void u_init_brifeInfo(string rdn) { SqlConnect conn = new SqlConnect(); string sql = "select * from dbo.JCI_patient_brifeInfo where rdn=" + rdn; //if() UserPower user = Session["user"] as UserPower; if (user == null) { PowerManage(); } else { if (user.IsUser()) { sql += " and dept='" + user.UserDeptName + "'"; } } DataTable dt = conn.ExcuteSelect(sql); DataRow dr = dt.Rows[0]; tbox_reportDate.Text = dr["regDept"].ToString(); tbox_fillPerson.Text = dr["fillPerson"].ToString(); tbox_once.Text = dr["isFirst"].ToString(); tbox_other1.Text = dr["other1"].ToString(); tbox_personSex.Text = dr["personSex"].ToString(); tbox_regDate.Text = Convert.ToDateTime(dr["regDate"]).ToString("yyy-MM-dd"); tbox_ddl_dept.Text = dr["dept"].ToString(); tbox_ddl_floor.Text = dr["floorName"].ToString(); tbox_job.Text = dr["job"].ToString(); tbox_pay.Text = dr["payType"].ToString(); string promote = dr["promote"].ToString(); string needImprove = dr["needImprove"].ToString(); string[] promotes = promote.Split(';'); string[] needImproves = needImprove.Split(';'); tbox_promote_yl.Text = promotes[0].Split(':')[1]; tbox_promote_hl.Text = promotes[1].Split(':')[1]; tbox_promote_yj.Text = promotes[2].Split(':')[1]; tbox_promote_hq.Text = promotes[3].Split(':')[1]; tbox_promote_zy.Text = promotes[4].Split(':')[1]; tbox_needImprove_yl.Text = needImproves[0].Split(':')[1]; tbox_needImprove_hl.Text = needImproves[1].Split(':')[1]; tbox_needImprove_yj.Text = needImproves[2].Split(':')[1]; tbox_needImprove_hq.Text = needImproves[3].Split(':')[1]; tbox_needImprove_zy.Text = needImproves[4].Split(':')[1]; }
/*** * **/ public int getNewRecipeId() { int id; SqlConnect sql = new SqlConnect(); //sql.executeStoredPrcedure("GetRecipe"); sql.retriveData("select top 1 id from Recipe order by id desc"); id = Convert.ToInt32(sql.sqlTable.Rows[0]["id"]); System.Diagnostics.Debug.Print("Next ID: " + (id + 1)); return(id + 1); }
public ObjectDetail(DataRow row, Point location) { InitializeComponent(); label5.Text = row["c_ID"].ToString(); label6.Text = row["c_Identifier"].ToString(); OdbcDataReader read = SqlConnect.ExecuteDataReader("*", "DictionaryEntryTbl", "c_ID = " + row["OPT"].ToString()); read.Read(); label7.Text = read["c_value"].ToString(); read.Close(); read = SqlConnect.ExecuteDataReader("*", "DictionaryEntryTbl", "c_ID = " + row["KRG"].ToString()); read.Read(); label8.Text = read["c_value"].ToString(); read.Close(); this.Location = location; }
/// <summary> /// 获取服务下的库 /// </summary> /// <param name="sqlconnect"></param> /// <returns></returns> public async Task <ActionResult> GetServerDbList(SqlConnect sqlconnect) { sqlconnect.DbName = ""; string strConn = ""; if (sqlconnect.SqlType == FreeSql.DataType.MySql) { strConn = $"server={sqlconnect.Host}:{sqlconnect.Port};database={sqlconnect.DbName};uid={sqlconnect.Account};pwd={sqlconnect.Pwd};charset='utf8'"; } else { strConn = $"data source={sqlconnect.Host},{sqlconnect.Port};initial catalog={sqlconnect.DbName};persist security info=True;user id={sqlconnect.Account};password={sqlconnect.Pwd};"; } sqlconnect.Address = strConn; return(ServerDbList(sqlconnect)); }
public bool Delete(string rdn) { try { string sql = "delete from dbo.JCI_patient_brifeInfo where rdn = " + rdn; SqlConnect conn = new SqlConnect(); conn.ExcuteCmd(sql); sql = "delete from dbo.JCI_detailInfo where typefrom='" + this.tableType + "' and applyRdn = " + rdn; conn.ExcuteCmd(sql); } catch (Exception ex) { throw; } return(true); }
/// <summary> /// Search Car to Gara /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void searchGara(string bsx, string hangXe) { string query; SqlConnect connect = new SqlConnect(); if (bsx == "") { query = "select * from THONGTINXE where HangXe = '" + hangXe + "'"; dgvGara.DataSource = connect.ExecuteQuery(query); } else { query = "select * from THONGTINXE where HangXe = '" + hangXe + "' and BienSoXe like '" + bsx + "%'"; dgvGara.DataSource = connect.ExecuteQuery(query); } }
private static bool insertRow(string c_ID, List <Tuple <string, int, int> > docs, bool reverse) { bool ret = true; foreach (Tuple <string, int, int> doc in docs) { string docPath = DataManip.DataManip.GenerateDocumentPath(); string command = "INSERT INTO DocumentTbl VALUES (" + c_ID + ",'" + doc.Item1 + "', NULL ,'" + docPath + doc.Item1 + ".pdf'," + DataManip.DataManip.SłownikIDTypow[doc.Item3] + ",'" + geodezja.geodezja.DocumentsAlias + "',1)"; if (reverse) { command = "INSERT INTO DocumentTbl VALUES (" + c_ID + ",'" + doc.Item1 + "', NULL ,'" + docPath + doc.Item1 + ".pdf'," + DataManip.DataManip.SłownikIDTypow[doc.Item2] + ",'" + geodezja.geodezja.DocumentsAlias + "',1)"; } ret = ret && SqlConnect.ExecuteCommand(command); } return(ret); }
public UserAutoViewModel() { SqlConnect spam = new SqlConnect(); if (!spam.IsAdminById()) { PanelVisability = true; PanelVisabilityComboBox = false; PhoneNumber = Properties.Settings.Default.User; SqlConnectionCar record = new SqlConnectionCar(); ObservableCollection <Car> carsDB = record.GiveUsersRecordsByPhoneNumber(PhoneNumber); CarsCollection = new ObservableCollection <Car>(); if (carsDB != null) { foreach (var item in carsDB) { CarsCollection.Add(item); } } if (CarsCollection.Count != 0) { var carNumber = (from number in CarsCollection select number.CarNumber); CarNumber = carNumber.First(); var carRegion = (from region in CarsCollection select region.CarRegion); CarRegion = carRegion.First(); var carSeries = (from series in CarsCollection select series.CarSeries); CarSeries = carSeries.First(); var carSpace = (from space in CarsCollection select space.SpaceType); SpaceType = carSpace.First(); var leaseTime = (from time in CarsCollection select time.LeaseTime); LeaseTime = leaseTime.First(); dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); } } else { PanelVisability = false; PanelVisabilityComboBox = true; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Display_dates(object sender, RoutedEventArgs e) { DateTime? start = Start.SelectedDate; DateTime? end = Start.SelectedDate; RowNumbers rows = Application.Current.Resources["RowNumbers"] as RowNumbers; SqlConnect dbconnect = new SqlConnect(); Json311 get_data = new Json311(); List <Json311> show_data = new List <Json311>(); if (!start.HasValue) { MessageBox.Show("Select a date on the left"); } else if (start.HasValue && !end.HasValue) { DateTime new_start = (DateTime)start; int year = new_start.Year; int month = new_start.Month; int date = new_start.Day; DateTime date1 = new DateTime(year, month, date, 0, 0, 0); DateTime date2 = new DateTime(year, month, date, 23, 59, 59); int num_rows = dbconnect.GetRows(date1, date2); if (num_rows == 0) { MessageBox.Show("There are no values for the selected dates"); } else { rows.filter_min = 0; if (num_rows > 500) { rows.filter_max = 500; } else { rows.filter_max = num_rows; } rows.filter_total = num_rows; rows.is_filter = true; show_data = get_data.GetDateFilteredList(0, 0, date1, date2); DBDataBinding.ItemsSource = show_data; this.NavigationService.Refresh(); } } Application.Current.Resources["RowNumbers"] = rows; }
public static void FillObrebSelectCombo(string JEwidencyjnaText, ComboBox ObrebSelectCombo) { if (ObrebSelectCombo.Items.Count < 1) { OdbcDataReader rd = SqlConnect.ExecuteDataReader("SystematicsTbl.c_ID,c_parent_ID,c_name,c_description", "SystematicsTbl, (SELECT c_ID FROM SystematicsTbl WHERE c_name LIKE '" + JEwidencyjnaText + "') AS querry", "SystematicsTbl.c_parent_ID = querry.c_ID ORDER BY c_name;"); if (rd.HasRows) { string name; while (rd.Read()) { name = rd["c_name"].ToString() + " - " + rd["c_description"].ToString(); ObrebSelectCombo.Items.Add(name); } } rd.Close(); } }
private void getData() { SqlConnect sql = new SqlConnect(); using (SqlCommand query = new SqlCommand("select * from ToDoList Where ID = " + Request.QueryString["ID"], sql.connection())) { SqlDataAdapter adapter = new SqlDataAdapter(query); DataTable dt = new DataTable(); adapter.Fill(dt); SubjectTitleTextBox.Text = dt.Rows[0][2].ToString(); SubjectTextBox.Text = dt.Rows[0][3].ToString(); DateTextBox.Text = dt.Rows[0][4].ToString(); Status.SelectedValue = dt.Rows[0][5].ToString(); } sql.disconnection(); }
public int getIsPassedCount(string type, string dept, string power) { //0:未审核 1:审核 int result = 0; string sql = ""; switch (type) { case "0": if ("管理员".Equals(power)) { sql = "select count(*) from dbo.JCI_acc_brifeInfo where (deleteFlag <>'1' or deleteFlag is null) and (ispassed='0' or ispassed is null)"; } else { sql = "select count(*) from dbo.JCI_acc_brifeInfo where (deleteFlag <>'1' or deleteFlag is null) and (ispassed='0' or ispassed is null) and reportDept='" + dept + "'"; } break; case "1": if ("管理员".Equals(power)) { sql = "select count(*) from dbo.JCI_acc_brifeInfo where (deleteFlag <>'1' or deleteFlag is null) and ispassed='1'"; } else { sql = "select count(*) from dbo.JCI_acc_brifeInfo where (deleteFlag <>'1' or deleteFlag is null) and ispassed='1' and reportDept='" + dept + "'"; } break; default: break; } try { SqlConnect conn = new SqlConnect(); DataTable dt = conn.ExcuteSelect(sql); result = Convert.ToInt16(dt.Rows[0][0]); } catch (Exception ex) { throw ex; } return(result); }
protected void Button1_Click(object sender, EventArgs e) { connect = new SqlConnect(); string eid = TextBox1.Text; string ename = TextBox2.Text; int sal = int.Parse(TextBox3.Text); string dep = DropDownList1.SelectedValue.ToString(); int res = connect.addEmp(eid, ename, sal, dep); if (res > 0) { Response.Redirect("~/Employee.aspx"); } else { Response.Write("Check Inputs!!"); } }
//输入提示 public string[] getDicContent(string keys) { string sql = "select top 20 dicItemContent from JCI_Dic where dicItemContent like '%" + keys + "%' or dicItemNickName like '%" + keys + "%'"; SqlConnect conn = new SqlConnect(); DataTable dt = conn.ExcuteSelect(sql); if (dt.Rows.Count == 0) { return(null); } string[] content = new string[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { content[i] = dt.Rows[i][0].ToString(); } return(content); }
public DataSet sDetailView(string id) { string sql = "select * from dbo.JCI_acc_brifeInfo where reportId=" + id; string sql1 = "select * from dbo.JCI_acc_detailInfo where tablerdn=" + id; try { DataSet ds = new DataSet(); SqlConnect conn = new SqlConnect(); ds.Tables.Add(conn.ExcuteSelect(sql)); ds.Tables.Add(conn.ExcuteSelect(sql1)); return(ds); } catch (Exception ex) { throw; } }
public void LoginCommand() { bool fl = true; bool IsDone = true; ErrorMes = ""; flag = true; Login += " "; int x1 = Login.Length - 1; Login = Login.Substring(0, x1); if (PasswordFieldText == String.Empty || PasswordFieldText == null) { fl = false; ErrorMes = Properties.Resources.emptyfield; } if (fl && canreg) { SqlConnect spam = new SqlConnect(); string Pass = firstHash(PasswordFieldText).ToString(); IsDone = spam.GiveUsersRecords(Login, Pass); if (IsDone) { Properties.Settings.Default.Language = "en"; LocalizeDictionary.Instance.SetCurrentThreadCulture = true; LocalizeDictionary.Instance.Culture = new CultureInfo("en"); Properties.Settings.Default.User = Login; Properties.Settings.Default.UserId = spam.GetIdUserByName(Login); Properties.Settings.Default.Save(); MainWindow sp = new MainWindow(); sp.WindowStartupLocation = WindowStartupLocation.CenterScreen; sp.Show(); CloseAction2(); } } if (!IsDone) { ErrorMes = Properties.Resources.nosuchuser; } flag = false; canreg = true; }
private void Form1_Load(object sender, EventArgs e) { //This is what happens when the form first loads. First we check if there is a connection that can be formed to the database we have. try { //Then it's checked to see if there is a connection to the database. if (SqlConnect.dataConnect() == true) { //Then an adapter is created that accesses the stored procedure that accesses all of the customers, using the connection that's //created in the data class. A datatable is also created that will hold the data later. SqlDataAdapter sqlAdapter = new SqlDataAdapter("dbo.sp_ActiveCustomerNames", SqlConnect.sqlConn); DataTable dtCombo = new DataTable(); //A couple of variables are created that will hold the information that will later be converted and put into our combo box. int CustomerID; string CustomerName; //The data adapter then populates our datatable with the data it retrieved from the stored procedure. sqlAdapter.Fill(dtCombo); //A foreach loop is created that will run as long as there is another row to access in the recently-populated datatable. foreach (DataRow drCustomers in dtCombo.Rows) { /* * While the loop is going, it puts values into the two variables created earlier. These values are the values in the * first and second cells of whatever row the foreach loop is currently on, the first cell going into CustomerID, and the * second into CustomerName. Then the variables are put into the combobox as a Combo Object (which is a custom class * created farther down.) */ CustomerID = int.Parse(drCustomers.ItemArray[0].ToString()); CustomerName = drCustomers.ItemArray[1].ToString(); cbCustomers.Items.Add(new ComboObject(CustomerID, CustomerName)); } } else { //This is for the occasion that the program is unable to connect to the SQL database. An exception is thrown telling the user //that the program failed to connect to the database. throw new Exception("Unable to connect to the AdventureWorks2012 database."); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SignIn_OnClick(object sender, RoutedEventArgs e) { var username = UsernameTxt.Text; var pass = PasswordTxt.SecurePassword; var result = SqlConnect.VerifyUser(username, pass); if (!result.Valid) { MessageBox.Show($@"Username or password is incorrect"); } else { Hide(); var incomeForm = new IncomeForm(result.Id); incomeForm.Closed += (s, args) => Close(); incomeForm.Show(); } }
public bool accept(string reportId, string passPerson, string passDate) { bool Succ = false; try { string sql = "update dbo.JCI_acc_brifeInfo set passPerson='" + passPerson + "',passDate='" + passDate + "',isPassed='1' where reportId=" + reportId; SqlConnect conn = new SqlConnect(); if (conn.ExcuteCmd(sql) > 0) { Succ = true; } } catch (Exception ex) { throw; } return(Succ); }
public IncomeForm(int userId) { InitializeComponent(); DataContext = new TextFields(); _userId = userId; _total = SqlConnect.PullData("total", _userId); _expense = SqlConnect.PullData("expense", _userId); _observableDataBanks = new ObservableCollection <SqlConnect.Bank>(_expense); // For testing //_random = new RandomListData().Generate(); DataGridExpense.ItemsSource = _observableDataBanks; _current = _total.Count >= 1 ? _total[_total.Count - 1].Money : 0; CurrentMoney.Text = _current.ToString("C"); }
public void getDetailInfo(string dept, string date1, string date2, GridView gv) { DataTable returndt, sourcedt; returndt = new DataTable(); sourcedt = new DataTable(); SqlConnect conn = new SqlConnect(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("select JCI_detailInfo.*,dbo.JCI_brifeInfo.mrn,dbo.JCI_brifeInfo.pName from JCI_detailInfo,JCI_brifeInfo where applyRdn in( "); sb.Append("select rdn from JCI_brifeInfo where docdept='" + dept + "' and convert(nvarchar(10),fillindate,120)>='" + date1 + "' and convert(nvarchar(10),fillindate,120)<='" + date2 + "'"); sb.Append(") and applyRdn=JCI_brifeInfo.Rdn and result<>'0' order by smallitemrdn asc"); sourcedt = conn.ExcuteSelect(sb.ToString()); int j = 0; returndt.Columns.Add("类别"); returndt.Columns.Add("项目"); returndt.Columns.Add("病历号"); for (int i = 0; i < sourcedt.Rows.Count; i++) { DataRow drNow = sourcedt.Rows[i]; if (i != 0) { DataRow drBefore = sourcedt.Rows[i - 1]; if (drNow["smallItemRdn"].ToString() != drBefore["smallItemRdn"].ToString())//新行 { returndt.Rows.Add(drNow["largeItemName"], drNow["smallItemName"], drNow["mrn"]); j++; } else { returndt.Rows[j - 1][2] += "," + drNow["mrn"].ToString(); } } else//第一行 { returndt.Rows.Add(drNow["largeItemName"], drNow["smallItemName"], drNow["mrn"]); j++; } } gv.DataSource = returndt; gv.DataBind(); }
private void deleteItem(GridViewCommandEventArgs e) { SqlConnect sql = new SqlConnect(); String sorgu = "Delete From ToDoList Where ID='" + e.CommandArgument + "'"; using (SqlCommand komut = new SqlCommand(sorgu, sql.connection())) { if (komut.ExecuteNonQuery() > 0) { GetData(); Functions.toastrGoster(this.Page, 0, " To-Do Silindi."); } else { Functions.toastrGoster(this.Page, 2, " To-Do Silinemedi!"); } sql.disconnection(); } }
public void JsonNull() { /// <remarks> /// Since data is often missing all fields are initialized to null if they do not have another value; /// </remarks> Json311 test = new Json311(); List <Json311> JList = new List <Json311>(); JList.Add(test); SqlConnect DBTest = new SqlConnect(); /// <remarks> /// Uses a test user who has only insert and select privelege in testtable /// </remarks> String connString = DBTest.Connect("test", "test", false); NpgsqlConnection conn = new NpgsqlConnection(connString); conn.Open(); /// <remarks> /// Check The connection /// </remarks> Assert.AreEqual(conn.State, System.Data.ConnectionState.Open); /// <remarks> /// Test the import, making sure the data is added to the right table /// and our date is not updated /// </remarks> DBTest.Import(JList, connString, "testtable", false); using (NpgsqlCommand checkValue = new NpgsqlCommand("SELECT * FROM testtable", conn)) using (NpgsqlDataReader reader = checkValue.ExecuteReader()) { while (reader.Read()) { /// <remarks> /// Since the column is empty, it will throw an invalid cast exception when /// attemption to convert it to a string /// </remarks> Assert.Throws <System.InvalidCastException>(() => { reader.GetString(0); }); } } conn.Close(); }
public static int DeleteEmployee(Employee e) { using (SqlConnection con = new System.Data.SqlClient.SqlConnection(SqlConnect.GetConString())) { string sCommand = "DELETE FROM Website..Employees WHERE EmpNo = @empno"; try { SqlCommand cmd = new SqlCommand(sCommand, con); cmd.Parameters.Add("@empno", SqlDbType.Int).Value = e.EmpNo; con.Open(); return(cmd.ExecuteNonQuery()); } catch (Exception ex) { Console.WriteLine(ex.Message); } } return(0); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (Session["power"] == null) { Response.Redirect("../Default.aspx"); } if (!srrshPage.Level2(Session["power"].ToString())) { Response.Redirect("../Err/powerNeed.aspx"); //没权限 } string sql = "select * from JCI_generateTable where tablerdn=13"; SqlConnect conn = new SqlConnect(); conn.gv_bind(sql, GridView1); }