private void btblogin_Click(object sender, EventArgs e) { SqlConnectionStringBuilder scab = new SqlConnectionStringBuilder(); scab.DataSource = "YL_SERVER";//网络地址 scab.UserID = "sa"; scab.Password = "******"; scab.InitialCatalog = "YouliData"; SqlConnection conn = new SqlConnection(scab.ToString()); //参数 连接数据库的字符串 if (conn.State == System.Data.ConnectionState.Closed) //判断连接的开启状态 { conn.Open(); string user_id = txtName.Text.Trim(); //获取用户名 string user_pwd = txtPwd.Text.Trim(); //获取密码 string strSQL = "SELECT userPwd FROM userAdmin WHERE [userID]='" + user_id + "' "; SqlCommand comm = new SqlCommand(strSQL, conn); //发送查询语句 SqlDataReader dr = comm.ExecuteReader(); if (dr.Read()) //如果能读到用户名 { // MessageBox.Show(dr["userPwd"].ToString(), user_pwd); String an = dr["userPwd"].ToString(); if (dr["userPwd"].ToString() == user_pwd) { string loginName = txtName.Text.Trim(); INIHelper.Write("LoginName", "1", loginName, loginPath); if (checkBox1.Checked) { INIHelper.Write("LoginName", "2", user_pwd, loginPath); } // MessageBox.Show("登录成功!"); orderProcess frm_ord = new orderProcess(this.txtName.Text.Trim()); frm_ord.Show(); conn.Close(); this.Close(); } else { MessageBox.Show("密码错误!"); } } else { MessageBox.Show("用户名不存在!"); } } }
/// <summary> /// 提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { string login_host = Dns.GetHostName(); if (true) //if (b == "2016-20161129XI" || b == "YL-01010101") //String keyword02 = Interaction.InputBox("输入密码", "权限检查", "", -1, -1); { #region 保存权限02 string inipath = @"\\YL_SERVER\Youli_Server\工程问题资料汇总\data\Problems.ini"; string text2 = textBox2.Text.Replace("\r\n", " "); string text3 = textBox3.Text.Replace("\r\n", " "); string text4 = textBox4.Text.Replace("\r\n", " "); INIHelper.Write(this.textBox1.Text, "1", text2 + " " + "[用户:" + login_host + "][" + DateTime.Now.ToString("yyyy/MM/dd-hh:mm") + "]", inipath); INIHelper.Write(this.textBox1.Text, "2", text3 + " " + "[用户:" + login_host + "][" + DateTime.Now.ToString("yyyy/MM/dd-hh:mm") + "]", inipath); INIHelper.Write(this.textBox1.Text, "3", text4 + " " + "[用户:" + login_host + "][" + DateTime.Now.ToString("yyyy/MM/dd-hh:mm") + "]", inipath); #endregion MessageBox.Show("提交提示:" + "用户" + login_host + "\r\n您的修改已提交成功"); } else { // MessageBox.Show("当前用户无权限 请与工程部沟通!"); } //#region 图片修改保存 //try //{ // #region pic1 // //逻辑描述:1当窗体图片有、文件夹有图片时 (为原图片时报错) // if (pictureBox1.Image != null) // { // pictureBox1.Dispose(); // if (File.Exists(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "01" + ".bmp")) // { // // File.Delete(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "01" + ".bmp"); // pictureBox1.Image.Save(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "01" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic1", @"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "01" + ".bmp", inipath); // } // else // { // pictureBox1.Image.Save(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "01" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic1", @"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "01" + ".bmp", inipath); // } // } // else // { // if (File.Exists(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "01" + ".bmp")) // { // File.Delete(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "01" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic1", "null", inipath); // } // INIHelper.Write(this.textBox1.Text, "pic1", "null", inipath); // } // #endregion // #region pic2 // if (pictureBox2.Image != null) // { // pictureBox2.Dispose(); // if (File.Exists(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "02" + ".bmp")) // { // //pictureBox2.Dispose(); // File.Delete(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "02" + ".bmp"); // pictureBox2.Image.Save(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "02" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic2", @"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "02" + ".bmp", inipath); // //pictureBox2.Dispose(); // } // else // { // //pictureBox2.Dispose(); // pictureBox2.Image.Save(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "02" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic2", @"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "02" + ".bmp", inipath); // //pictureBox2.Dispose(); // } // } // else // { // if (File.Exists(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "02" + ".bmp")) // { // File.Delete(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "02" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic2", "null", inipath); // } // //pictureBox2.Dispose(); // INIHelper.Write(this.textBox1.Text, "pic2", "null", inipath); // } // #endregion // #region pic3 // if (pictureBox3.Image != null) // { // pictureBox3.Dispose(); // if (File.Exists(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "03" + ".bmp")) // { // File.Delete(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "03" + ".bmp"); // pictureBox3.Image.Save(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "03" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic3", @"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "03" + ".bmp", inipath); // } // else // { // pictureBox3.Image.Save(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "03" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic3", @"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "03" + ".bmp", inipath); // } // } // else // { // if (File.Exists(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "03" + ".bmp")) // { // File.Delete(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "03" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic3", "null", inipath); // } // INIHelper.Write(this.textBox1.Text, "pic3", "null", inipath); // } // #endregion // #region pic4 // if (pictureBox4.Image != null) // { // pictureBox4.Dispose(); // if (File.Exists(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "04" + ".bmp")) // { // File.Delete(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "04" + ".bmp"); // pictureBox4.Image.Save(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "04" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic4", @"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "04" + ".bmp", inipath); // } // else // { // pictureBox4.Image.Save(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "04" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic4", @"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "04" + ".bmp", inipath); // } // } // else // { // if (File.Exists(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "04" + ".bmp")) // { // File.Delete(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "04" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic4", "null", inipath); // } // INIHelper.Write(this.textBox1.Text, "pic4", "null", inipath); // } // #endregion // #region pic5 // if (pictureBox5.Image != null) // { // pictureBox5.Dispose(); // if (File.Exists(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "05" + ".bmp")) // { // File.Delete(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "05" + ".bmp"); // pictureBox5.Image.Save(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "05" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic5", @"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "05" + ".bmp", inipath); // } // else // { // pictureBox5.Image.Save(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "05" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic5", @"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "05" + ".bmp", inipath); // } // } // else // { // if (File.Exists(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "05" + ".bmp")) // { // File.Delete(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "05" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic5", "null", inipath); // } // INIHelper.Write(this.textBox1.Text, "pic5", "null", inipath); // } // #endregion // #region pic6 // if (pictureBox6.Image != null) // { // pictureBox6.Dispose(); // if (File.Exists(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "06" + ".bmp")) // { // File.Delete(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "06" + ".bmp"); // pictureBox6.Image.Save(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "06" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic6", @"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "06" + ".bmp", inipath); // } // else // { // pictureBox6.Image.Save(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "06" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic6", @"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "06" + ".bmp", inipath); // } // } // else // { // if (File.Exists(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "06" + ".bmp")) // { // File.Delete(@"\\YL_SERVER\Youli_Server\工程问题资料汇总\Picture\" + textBox1.Text + "06" + ".bmp"); // INIHelper.Write(this.textBox1.Text, "pic6", "null", inipath); // } // INIHelper.Write(this.textBox1.Text, "pic6", "null", inipath); // } // #endregion //} //catch (Exception) //{ // MessageBox.Show("error"); //} //#endregion }