/// <summary> /// 库存数量比对,重新设置库存数量 /// </summary> /// <param name="device_number">设备型号</param> /// <param name="device_count">下单数量</param> /// <returns></returns> public int GetIinventoryCount(string device_number, string device_count) { // 应该重新设置的库存数量 int count = -1; DataSet ds = OperaterBase.GetData("select * from Device_List where device_number = '" + device_number + "'"); // 说明查出来数据了 if (ds.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(device_count) > Convert.ToInt32(ds.Tables[0].Rows[0]["device_count"])) { Label1.Text = "下单数量大于库存数量,库存数量为" + Convert.ToInt32(ds.Tables[0].Rows[0]["device_count"]); } else { // 数量正常,可以正常减去 count = Convert.ToInt32(ds.Tables[0].Rows[0]["device_count"]) - Convert.ToInt32(device_count); OperaterBase.CommandBySql("update Device_List set device_count=" + count + " where device_number='" + device_number + "'"); } } else { Label1.Text = "设备号有异常,请检查"; } return(count); }
/// <summary> /// 获取出库列表 /// </summary> public void GetOutDeviceList() { DataSet ds = OperaterBase.GetData("select * from V_Out_Stock"); Repeater1.DataSource = ds; Repeater1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { string username = TextBox1.Text; string password = TextBox2.Text; string adminLoginSql = "select * from Staff_Table where worker_mobile='" + username + "' and worker_password='******'"; DataSet ds = OperaterBase.GetData(adminLoginSql); if (ds.Tables[0].Rows.Count == 0) { Label1.Text = "信息有误,请检查"; return; } // 存入session,判断session是否为空 Session["login_user"] = ds.Tables[0].Rows[0]["worker_mobile"]; if (string.IsNullOrEmpty(Session["login_user"].ToString())) { Label1.Text = "服务器错误,请联系管理员"; return; } // 必须是管理员 if (ds.Tables[0].Rows[0]["worker_num"].ToString() == "admin") { Response.Redirect("manage_staff.aspx?staffId=1"); } else { Response.Redirect("order_list.aspx?staffId=" + ds.Tables[0].Rows[0]["Id"]); } }
/// <summary> /// 添加或更新用户 /// </summary> public void AddUser() { // 传参设备id int deviceId = Convert.ToInt32(Request["deviceId"]); string device_number = TextBox1.Text.Trim(); int device_count = Convert.ToInt32(TextBox2.Text.Trim()); // 判断是否是插入还是更新 if (Button1.CommandName == "Insert") { int num = OperaterBase.CommandBySql( "insert into Device_List ( device_number, device_count, is_delete) values ('" + device_number + "'," + device_count + ",0)"); if (num > 0) { Label1.Text = "插入成功"; // 跳转页面 Response.Redirect("device_list.aspx"); } } else if (Button1.CommandName == "Update") { int num = OperaterBase.CommandBySql("update Device_List set device_number='" + device_number + "',device_count=" + device_count + " where id=" + deviceId); if (num > 0) { Label1.Text = "更新成功"; // 跳转页面 Response.Redirect("device_list.aspx"); } } }
protected void Button1_Click(object sender, EventArgs e) { // 获取传递过来的员工id string staffId = Request["staffId"]; string order_number = TextBox1.Text; string device_number = DropDownList1.SelectedItem.Text; string device_count = TextBox3.Text; // 库存设置 int count = GetIinventoryCount(device_number, device_count); if (count == -1) { return; } string sql = "insert into Order_List ( order_number,order_date,order_staff, device_id, device_count,is_delete)values ('" + order_number + "','" + DateTime.Now.ToString() + "','" + staffId + "','" + device_number + "','" + device_count + "',0)"; int num = OperaterBase.CommandBySql(sql); if (num > 0) { Response.Redirect("order_list.aspx?staffId=" + staffId); } }
/// <summary> /// 获取学生列表 /// </summary> private void getStudentList(string sql) { DataSet ds = OperaterBase.GetData(sql); Repeater1.DataSource = ds; Repeater1.DataBind(); }
/// <summary> /// 根据指定条件获取员工数据 /// </summary> private void GetStaffData(string sql) { DataSet ds = OperaterBase.GetData(sql); Repeater1.DataSource = ds; Repeater1.DataBind(); }
private void ResetPassword(string mobile, string password) { if (password != "") { string sql = "update studentInfo set password = '******' where mobile = '" + mobile + "'"; OperaterBase.commitBySql(sql); } }
/// <summary> /// 更新用户 /// 给文本框获取数据库原值 /// </summary> private void UpdateUser() { int deviceId = Convert.ToInt32(Request["deviceId"]); string sql = "select * from Device_List where id=" + deviceId; DataSet ds = OperaterBase.GetData(sql); TextBox1.Text = ds.Tables[0].Rows[0]["device_number"].ToString(); TextBox2.Text = ds.Tables[0].Rows[0]["device_count"].ToString(); }
/// <summary> /// 逻辑删除 /// </summary> private void isDelSql(int ID) { string delSql = "UPDATE studentInfo set isDelete = 1 where ID = " + ID + ";"; if (OperaterBase.CommitBySql(delSql) > 0) { string DelSql = "SELECT ID, studentName, studentNum, studentSex, mobile, password,birthday, province, city, district, isDelete from studentInfo where isDelete = 0;"; getStudentList(DelSql); } }
private void DropList1() { string sql = "select sp.ProvinceName,sp.ProvinceID from S_Province sp"; DataSet ds = OperaterBase.GetData(sql); DropDownList1.DataSource = ds; DropDownList1.DataTextField = "ProvinceName"; DropDownList1.DataValueField = "ProvinceID"; DropDownList1.DataBind(); }
private void GetClassList() { string sql = "select * from ClassInfo"; DataSet ds = OperaterBase.GetData(sql); DropDownList1.DataSource = ds; DropDownList1.DataValueField = "ID"; DropDownList1.DataTextField = "className"; DropDownList1.DataBind(); }
private void DropList3() { int value = Convert.ToInt32(DropDownList2.SelectedValue); string sql = "SELECT * FROM S_District WHERE CityID = " + value; DataSet ds = OperaterBase.GetData(sql); DropDownList3.DataSource = ds; DropDownList3.DataTextField = "DistrictName"; DropDownList3.DataValueField = "DistrictID"; DropDownList3.DataBind(); }
private void DropList2() { int value = Convert.ToInt32(DropDownList1.SelectedValue); string sql = "SELECT * FROM S_City WHERE ProvinceID = " + value; DataSet ds = OperaterBase.GetData(sql); DropDownList2.DataSource = ds; DropDownList2.DataTextField = "CityName"; DropDownList2.DataValueField = "CityID"; DropDownList2.DataBind(); }
/// <summary> /// 图片上传 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { string filename = AvatarUpload(); int ID = Convert.ToInt32(Request["staffId"]); if (Button1.CommandName == "Update") { OperaterBase.CommandBySql("update Staff_Table set worker_avatar='" + filename + "' where Id=" + ID + ""); } }
/// <summary> /// 获取设备型号 /// </summary> private void GetDeviceList() { DataSet ds = OperaterBase.GetData("select * from Device_List where is_delete=0 order by device_number"); DropDownList1.DataSource = ds; DropDownList1.DataTextField = "device_number"; DropDownList1.DataValueField = "id"; DropDownList1.DataBind(); // 插入到第一个位置,内容和value值 DropDownList1.Items.Insert(0, new ListItem("请选择设备编号", "0")); }
/// <summary> /// 判断手机号是否唯一 /// </summary> /// <param name="mobile"></param> /// <returns>true or false</returns> private Boolean IsMobile(string studentNum, string mobile) { string sql = "select mobile , studentNum from studentInfo where studentNum = '" + studentNum + "' or mobile = '" + mobile + "'"; DataSet ds = OperaterBase.GetData(sql); if (ds.Tables[0].Rows.Count <= 0) { return(true); } return(false); }
/// <summary> /// 获取订单列表 /// </summary> public void GetOrderList() { string staffId = Request["staffId"]; // 判断是否为空 if (!string.IsNullOrEmpty(staffId)) { DataSet ds = OperaterBase.GetData("select * from V_Order_Sta_Dev where order_staff= " + staffId); Repeater1.DataSource = ds; Repeater1.DataBind(); } }
private Boolean isMobile(string mobile, string password) { if (mobile != "") { string sql = "select mobile from studentInfo where mobile = '" + mobile + "'"; if (OperaterBase.GetData(sql) != null) { ResetPassword(mobile, password); return(true); } } return(false); }
/// <summary> /// 获取所有省份 /// </summary> private void GetAllProvince() { string sql = "select * from S_Province"; DataSet ds = OperaterBase.GetData(sql); // 给下拉框绑定 DropDownList1.DataSource = ds; // 绑定下拉框文字 DropDownList1.DataTextField = "ProvinceName"; //绑定下拉框value值 DropDownList1.DataValueField = "ProvinceID"; DropDownList1.DataBind(); DropDownList1.Items.Insert(0, new ListItem("请选择省份", "0")); }
/// <summary> /// 添加修改用户 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button2_Click(object sender, EventArgs e) { int ID = Convert.ToInt32(Request["staffId"]); string worker_num = TextBox1.Text.Trim(); string worker_name = TextBox2.Text.Trim(); string worker_avatar = Image1.ImageUrl; string worker_sex = Sex_Tb.SelectedValue.Trim(); string worker_age = TextBox4.Text.Trim(); string worker_mobile = TextBox5.Text.Trim(); string worker_password = TextBox6.Text.Trim(); string DropDownList1Text = DropDownList1.SelectedItem.Text; string DropDownList2Text = DropDownList2.SelectedItem.Text; string DropDownList3Text = DropDownList3.SelectedItem.Text; string sql = String.Empty; try { if (Button2.CommandName == "Insert") { sql = "insert into Staff_Table ( worker_num, worker_name, worker_avatar, worker_sex, worker_age, worker_mobile, worker_password, is_delete,s_province,s_city,s_district) values ('" + worker_num + "','" + worker_name + "','" + worker_avatar + "','" + worker_sex + "','" + worker_age + "','" + worker_mobile + "','" + worker_password + "',0,'" + DropDownList1Text + "','" + DropDownList2Text + "','" + DropDownList3Text + "')"; } else if (Button2.CommandName == "Update") { sql = "UPDATE Staff_Table SET worker_num = '" + worker_num + "', worker_name = '" + worker_name + "'," + " worker_sex = '" + worker_sex + "' , worker_age = '" + worker_age + "'," + "worker_mobile = '" + worker_mobile + "' , worker_password = '******' , s_province = '" + DropDownList1Text + "' , s_city = '" + DropDownList2Text + "' , s_district = '" + DropDownList3Text + "'where Id = " + ID; } int flag = OperaterBase.CommandBySql(sql); if (flag > 0) { // 跳转页面 Response.Redirect("manage_staff.aspx"); } } catch (Exception exception) { Console.WriteLine(exception); throw; } }
/// <summary> /// 获取选定城市的区县 /// </summary> private void GetSelectedDistrict() { string CityID = DropDownList2.SelectedValue; string sql = "select * from S_District where CityID=" + CityID + ""; DataSet ds = OperaterBase.GetData(sql); // 给下拉框绑定 DropDownList3.DataSource = ds; // 绑定下拉框文字 DropDownList3.DataTextField = "DistrictName"; //绑定下拉框value值 DropDownList3.DataValueField = "DistrictID"; DropDownList3.DataBind(); DropDownList3.Items.Insert(0, new ListItem("请选择地区", "0")); }
/// <summary> /// 把数据 填入框里面 /// </summary> /// <param name="StudentID"></param> private void FillData(int StudentID) { string Bysql = "select * from studentInfo where ID = " + StudentID; DataSet ds = OperaterBase.GetData(Bysql); TextBox1.Text = ds.Tables[0].Rows[0]["studentNum"].ToString(); TextBox2.Text = ds.Tables[0].Rows[0]["studentSex"].ToString(); TextBox3.Text = ds.Tables[0].Rows[0]["mobile"].ToString(); TextBox4.Text = ds.Tables[0].Rows[0]["password"].ToString(); TextBox5.Text = ds.Tables[0].Rows[0]["birthday"].ToString(); TextBox6.Text = ds.Tables[0].Rows[0]["province"].ToString(); TextBox7.Text = ds.Tables[0].Rows[0]["city"].ToString(); TextBox8.Text = ds.Tables[0].Rows[0]["district"].ToString(); TextBox10.Text = ds.Tables[0].Rows[0]["classId"].ToString(); TextBox9.Text = ds.Tables[0].Rows[0]["studentName"].ToString(); }
protected void Button1_Click(object sender, EventArgs e) { string user = TextBox1.Text.Trim(); string pwd = TextBox2.Text.Trim(); string sql = "SELECT studentNum,password FROM studentInfo WHERE studentNum = " + user + " AND password = "******"登录成功"; } else { Button1.Text = "登录失败"; } Response.Redirect("studentInfo.aspx"); }
/// <summary> /// 修改员工信息 /// </summary> private void UpdateStaff() { var ID = Convert.ToInt32(Request["staffID"]); string sql = "select * from Staff_Table where Id=" + ID + ""; DataSet ds = OperaterBase.GetData(sql); TextBox1.Text = ds.Tables[0].Rows[0]["worker_num"].ToString(); TextBox2.Text = ds.Tables[0].Rows[0]["worker_name"].ToString(); Image1.ImageUrl = ds.Tables[0].Rows[0]["worker_avatar"].ToString(); Sex_Tb.SelectedValue = ds.Tables[0].Rows[0]["worker_sex"].ToString(); TextBox4.Text = ds.Tables[0].Rows[0]["worker_age"].ToString(); TextBox5.Text = ds.Tables[0].Rows[0]["worker_mobile"].ToString(); TextBox6.Text = ds.Tables[0].Rows[0]["worker_password"].ToString(); DropDownList1.SelectedValue = ds.Tables[0].Rows[0]["s_province"].ToString(); DropDownList2.SelectedValue = ds.Tables[0].Rows[0]["s_city"].ToString(); DropDownList3.SelectedValue = ds.Tables[0].Rows[0]["s_district"].ToString(); }
/// <summary> /// 获取选定省份的城市 /// </summary> private void GetSelectedCity() { string ProvinceID = DropDownList1.SelectedValue; string sql = "select * from S_City where ProvinceID=" + ProvinceID + ""; DataSet ds = OperaterBase.GetData(sql); // 给下拉框绑定 DropDownList2.DataSource = ds; // 绑定下拉框文字 DropDownList2.DataTextField = "CityName"; //绑定下拉框value值 DropDownList2.DataValueField = "CityID"; DropDownList2.DataBind(); DropDownList2.Items.Insert(0, new ListItem("请选择城市", "0")); // 改变省份清除区县 DropDownList3.Items.Clear(); DropDownList3.Items.Insert(0, new ListItem("请选择地区", "0")); }
/// <summary> /// 表格更新或删除功能 /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { int deviceId = Convert.ToInt32(((HiddenField)e.Item.FindControl("HiddenField1")).Value); if (e.CommandName == "Delete") { string sql = "update Device_List set is_delete=1 where id = " + deviceId; int flag = OperaterBase.CommandBySql(sql); if (flag > 0) { Response.Write("<script type='text/javascript'>alert(成功删除:'" + flag + "'条数据);</script>"); DropDownList1_SelectedIndexChanged(null, null); } } else if (e.CommandName == "Edit") { Response.Redirect("add_device.aspx?deviceId=" + deviceId); } }
protected void Button1_Click(object sender, EventArgs e) { string worker_mobile = TextBox1.Text; // string worker_password = TextBox2.Text; string worker_password = TextBox2.Text; DataSet ds = OperaterBase.GetData("select * from Staff_Table where worker_mobile='" + worker_mobile + "' and worker_password='******'"); if (ds.Tables[0].Rows.Count > 0) { bool CheckBoxResult = CheckBox1.Checked; if (CheckBoxResult) { CookieHelper.SetCookie("worker_mobile", ds.Tables[0].Rows[0]["worker_mobile"].ToString(), DateTime.Now.AddMinutes(10)); CookieHelper.SetCookie("worker_password", ds.Tables[0].Rows[0]["worker_password"].ToString(), DateTime.Now.AddMinutes(10)); CookieHelper.SetCookie("remember_password", CheckBox2.Checked.ToString(), DateTime.Now.AddMinutes(10)); CookieHelper.SetCookie("auto_login", CheckBox2.Checked.ToString(), DateTime.Now.AddMinutes(10)); CookieHelper.SetCookie("Id", ds.Tables[0].Rows[0]["Id"].ToString(), DateTime.Now.AddMinutes(10)); } else { Session["worker_mobile"] = ds.Tables[0].Rows[0]["worker_mobile"]; Session["worker_password"] = ds.Tables[0].Rows[0]["worker_password"]; } // 必须是管理员 if (ds.Tables[0].Rows[0]["worker_num"].ToString() == "admin") { Response.Redirect("manage_staff.aspx?staffId=1"); } else { Response.Redirect("order_list.aspx?staffId=" + ds.Tables[0].Rows[0]["Id"]); } } }
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { int staffId = Convert.ToInt32(((HiddenField)e.Item.FindControl("staffId")).Value); // 删除员工 if (e.CommandName == "Delete") { string sql = "update Staff_Table set is_delete=1 where Id=" + staffId + ""; int flag = OperaterBase.CommandBySql(sql); if (flag > 0) { Response.Write("<script type='text/javascript'>alert(成功删除:'" + flag + "'条数据);</script>"); GetStaffData("select * from Staff_Table where is_delete=0"); } } else if (e.CommandName == "Edit") { Response.Redirect("add_staff.aspx?staffId=" + staffId); } }
/// <summary> /// 锁定员工姓名 /// </summary> private void GetStaffDetail() { // 获取传递过来的员工id string staffId = Request["staffId"]; if (!string.IsNullOrEmpty(staffId)) { DataSet ds = OperaterBase.GetData("select * from Staff_Table where is_delete=0 and Id=" + staffId); // 如果查询到数据,给员工姓名textBox赋值,并向隐藏控件赋值id if (ds.Tables[0].Rows.Count > 0) { TextBox4.Text = ds.Tables[0].Rows[0]["worker_name"].ToString(); HiddenField1.Value = ds.Tables[0].Rows[0]["Id"].ToString(); } // 查不到跳转到登录页面 else { Response.Redirect("manage_staff_login.aspx"); } } }