protected void yes_Click(object sender, EventArgs e) { if (new_ps.Text != again_ps.Text) { Response.Write("<script language='javascript' type='text/javascript'> alert('修改失败,两次输入新密码不一致,请重新输入')</script>"); return; } string sqlStr = "select * from K_Employee where Emp_account='" + Session["yhm"] + "' and Emp_password='******' and Emp_company='" + Session["company"] + "'"; DbSql ds = new DbSql(); DataTable da = new DataTable(); da = ds.FillDt(sqlStr); if (da.Rows.Count > 0) { sqlStr = "update K_Employee set Emp_password='******' where Emp_id='" + Session["Emp_id"] + "'"; if (ds.ExecSql(sqlStr)) { Session["yhm"] = null; Response.Write("<script language='javascript' type='text/javascript'> alert('修改成功,请重新登录页面');window.parent.location.href='../Login.aspx';</script>"); } else { Response.Write("<script language='javascript' type='text/javascript'> alert('修改失败,请重试或联系系统管理员')</script>"); } } else { Response.Write("<script language='javascript' type='text/javascript'> alert('密码错误或用户名不存在')</script>"); } }
private int addPurchasing(Data data) { string sqlStr = ""; int arraySize = data.A_Pc_parameter.Length; for (int i = 0; i < arraySize; i++) { data.Pc_parameter = data.A_Pc_parameter[i]; data.Pc_purpose = data.A_Pc_purpose[i]; data.Pc_quantity = data.A_Pc_quantity[i]; data.Pc_typeId = data.A_Pc_typeId[i]; data.Pc_unitPrice = data.A_Pc_unitPrice[i]; data.Pc_remarks = data.A_Pc_remarks[i]; if (data.Pc_Method.IndexOf("入库") > -1) { sqlStr += addInventory(data); } if (data.Pc_Method.IndexOf("入账") > -1) { sqlStr += addFinancial(data); } sqlStr += getPurchasing(data); } DbSql ds = new DbSql(); //将数据添加进采购管理数据表中 if (!ds.ExecSql(sqlStr)) { return(0); } return(2); }
private string insertDB(DataTable dt) { try { int errorcount = 0; //记录错误信息条数 int insertcount = 0; //记录插入成功条数 DbSql sqldb = new DbSql(); for (int i = 0; i < dt.Rows.Count; i++) { string sqlStr = "insert into K_TaobaoOrder values ("; for (int j = 0; j < 45; j++) { sqlStr += "'" + dt.Rows[i][j].ToString().Replace("\'", "''") + "' ,"; } sqlStr = sqlStr.Substring(0, sqlStr.Length - 1) + ")"; if (sqldb.ExecSql(sqlStr)) { insertcount++; } else { errorcount++; } } return("{ error:'',msg:'导入成功" + insertcount + "条数据导入成功!" + errorcount + "条数据部分信息为空没有导入!'}"); } catch (Exception ex) { return("{ error:'导入失败,插入数据库失败,请重试或联系管理员'}"); } }
//更新客户的信息 private string UpdateInfo(Data data) { string sqlStr = " update K_CustomerInfo set Ci_sex='" + data.sex + "',Ci_name='" + data.name + "',Ci_email='" + data.email + "',Ci_phone='" + data.phone + "',Ci_city='" + data.city + "',Ci_vipLevel='" + data.level + "',Ci_vipState='" + data.state + "',Ci_address='" + data.addr + "',Ci_marks='" + data.marks + "',Ci_rank='" + data.rank + "',Ci_birth='" + data.birth + "',Ci_tradeAmount='" + data.tradeAmount + "',Ci_goodsNum='" + data.goodsNum + "',Ci_tradeCloseNum='" + data.tradeClose + "',Ci_isInfoNew='" + 1 + "' where Ci_infoId='" + data.infoName + "'"; DbSql ds = new DbSql(); if (ds.ExecSql(sqlStr)) { return(GetOldCustomer()); //成功 } return("0"); //失败 }
private void updateProduct(string id) { string sqlStr = "UPDATE K_Product SET Pd_inventory=(SELECT SUM(SKU_inventory) FROM K_ProductSku WHERE SKU_pdId='" + id + "') WHERE Pd_id='" + id + "';"; sqlStr += "UPDATE K_Product SET Pd_SKU =(SELECT COUNT(*) FROM K_ProductSku WHERE SKU_pdId='" + id + "') WHERE Pd_id='" + id + "'"; sqlStr += "UPDATE K_Product SET Pd_price =(SELECT (SELECT convert(nvarchar(20),MIN(SKU_price )) FROM K_ProductSku WHERE SKU_pdId='" + id + "')+'-'+convert(nvarchar(20),MAX(SKU_price)) FROM K_ProductSku WHERE SKU_pdId='" + id + "') WHERE Pd_id='" + id + "'"; DbSql ds = new DbSql(); ds.ExecSql(sqlStr); }
private string onJob(Data data) { string sqlStr = " update K_Employee set Emp_name='" + data.Emp_name + "',Emp_deptId='" + data.Emp_deptId + "',Emp_sex='" + data.Emp_sex + "',Emp_birthday='" + data.Emp_birthday + "',Emp_idcard='" + data.Emp_idcard + "',Emp_address='" + data.Emp_address + "',Emp_nowAddress='" + data.Emp_nowAddress + "',Emp_phone='" + data.Emp_phone + "',Emp_positionId='" + data.Emp_positionId + "' where Emp_id='" + data.Emp_id + "'"; DbSql ds = new DbSql(); if (ds.ExecSql(sqlStr)) { return("2"); //成功 } return("0"); //失败 }
private string onJob(Data data) { string sqlStr = " update K_onoffDutyData set " + getSqlStr(data) + " where O_checkDate='" + data.O_checkDate + "' and O_employeeId='" + data.Emp_id + "'"; DbSql ds = new DbSql(); if (ds.ExecSql(sqlStr)) { return("2"); //成功 } return("0"); //失败 }
private string onJob(Data data) { string sqlStr = " insert into K_Employee (Emp_account,Emp_name,Emp_password,Emp_deptId,Emp_sex,Emp_birthday,Emp_idcard,Emp_address,Emp_nowAddress,Emp_phone,Emp_positionId,Emp_company) values ('" + data.Emp_account + "','" + data.Emp_name + "','123456','" + data.Emp_deptId + "','" + data.Emp_sex + "','" + data.Emp_birthday + "','" + data.Emp_idcard + "','" + data.Emp_address + "','" + data.Emp_nowAddress + "','" + data.Emp_phone + "','" + data.Emp_positionId + "','" + data.Emp_company + "')"; DbSql ds = new DbSql(); if (ds.ExecSql(sqlStr)) { return("2"); //成功 } return("0"); //失败 }
private string addNew(Data data) { string sqlStr = " insert into K_Outlay (Ol_payDate,Ol_payee,Ol_money,Ol_content,Ol_remarks,Ol_company,Ol_editDate,Ol_state,Ol_operator) values ('" + data.Ol_payDate + "','" + data.Ol_payee + "','" + data.Ol_money + "','" + data.Ol_content + "','" + data.Ol_remarks + "','" + data.Ol_company + "','" + data.Ol_editDate + "','" + data.Ol_state + "','" + data.Ol_operator + "')"; DbSql ds = new DbSql(); if (ds.ExecSql(sqlStr)) { return("2"); //成功 } return("0"); //失败 }
private string setUrl(string data, string id) { string sqlStr = "Update K_Employee set Emp_indexUrl='" + data + "' where Emp_id='" + id + "'"; DbSql ds = new DbSql(); DataTable da = new DataTable(); if (ds.ExecSql(sqlStr)) { return("1"); } return("0"); }
private string addNew(Data data) { string sqlStr = " insert into K_Income (Ic_payDate,Ic_payer,Ic_money,Ic_content,Ic_remarks,Ic_company,Ic_editDate,Ic_state,Ic_operator) values ('" + data.Ic_payDate + "','" + data.Ic_payer + "','" + data.Ic_money + "','" + data.Ic_content + "','" + data.Ic_remarks + "','" + data.Ic_company + "','" + data.Ic_editDate + "','" + data.Ic_state + "','" + data.Ic_operator + "')"; DbSql ds = new DbSql(); if (ds.ExecSql(sqlStr)) { return("2"); //成功 } return("0"); //失败 }
private string setPermission(Data data, HttpContext context) { string sqlStr = " update K_Employee set Emp_permissions='" + data.permissions + "' where Emp_id='" + data.id + "'"; DbSql ds = new DbSql(); if (ds.ExecSql(sqlStr)) { reloadPermission(context); return("2"); //成功 } return("0"); //失败 }
private int addComponent(Data data) { string sqlStr = ""; DbSql ds = new DbSql(); sqlStr = "INSERT INTO K_Component (Cp_typeId, Cp_manufacturerId, Cp_parameter, Cp_price, Cp_unit, Cp_inventory, Cp_remarks, Cp_pictrue,Cp_company) VALUES ('" + data.Cp_typeId + "', '" + data.Cp_manufacturerId + "', '" + data.Cp_parameter + "', '" + Double.Parse(0 + data.Cp_price) + "','" + data.Cp_unit + "', '" + Double.Parse(0 + data.Cp_inventory) + "','" + data.Cp_remarks + "','" + data.Cp_pictrue + "','" + data.company + "')"; if (!ds.ExecSql(sqlStr)) { return(0); } return(2); }
private int addComponent(Data data) { //返回2代表修改成功,返回0代表数据库添加失败 string sqlStr = "UPDATE K_Component SET Cp_typeId='" + data.Cp_typeId + "', Cp_manufacturerId= '" + data.Cp_manufacturerId + "',Cp_parameter= '" + data.Cp_parameter + "',Cp_price= '" + Double.Parse(data.Cp_price) + "',Cp_unit='" + data.Cp_unit + "',Cp_inventory= '" + Double.Parse(data.Cp_inventory) + "',Cp_remarks='" + data.Cp_remarks + "',Cp_pictrue='" + data.Cp_pictrue + "' WHERE Cp_id='" + data.Cp_id + "'"; DbSql ds = new DbSql(); DataTable da = new DataTable(); if (!ds.ExecSql(sqlStr)) { return(0); } return(2); }
private string incomeEdit(Data data) { string sqlStr = " update K_Outlay set Ol_payDate='" + data.Ol_payDate + "',Ol_payee='" + data.Ol_payee + "',Ol_payMethod='" + data.Ol_payMethod + "',Ol_money='" + data.Ol_money + "',Ol_content='" + data.Ol_content + "',Ol_operator='" + data.Ol_operator + "',Ol_remarks='" + data.Ol_remarks + "',Ol_editDate='" + data.Ol_editDate + "' where Ol_id='" + data.Ol_id + "'"; DbSql ds = new DbSql(); if (ds.ExecSql(sqlStr)) { return("2"); //成功 } return("0"); //失败 }
private string incomeEdit(Data data) { string sqlStr = " update K_Income set Ic_payDate='" + data.Ic_payDate + "',Ic_payer='" + data.Ic_payer + "',Ic_payMethod='" + data.Ic_payMethod + "',Ic_money='" + data.Ic_money + "',Ic_content='" + data.Ic_content + "',Ic_operator='" + data.Ic_operator + "',Ic_remarks='" + data.Ic_remarks + "',Ic_editDate='" + data.Ic_editDate + "' where Ic_id='" + data.Ic_id + "'"; DbSql ds = new DbSql(); if (ds.ExecSql(sqlStr)) { return("2"); //成功 } return("0"); //失败 }
protected void yes_Click(object sender, EventArgs e) { string sqlStr = "UPDATE K_Purchasing SET Pc_isValid='0' WHERE "; string[] sArray = Request.QueryString["Pc_id"].ToString().Split(','); foreach (string i in sArray) { sqlStr += " Pc_id='" + i + "' or"; } sqlStr = sqlStr.Substring(0, sqlStr.Length - 3); DbSql ds = new DbSql(); if (!ds.ExecSql(sqlStr)) { Response.Write("<script language='javascript' type='text/javascript'> alert('操作失败,请重试或者检查网络联系管理员')</script>"); } workOut(); }
protected void yes_Click(object sender, EventArgs e) { string sqlStr = "DELETE FROM k_ProductType WHERE "; string[] sArray = Request.QueryString["delData"].ToString().Split(','); foreach (string i in sArray) { sqlStr += " Tp_id='" + i + "' or"; } sqlStr = sqlStr.Substring(0, sqlStr.Length - 3); DbSql ds = new DbSql(); if (!ds.ExecSql(sqlStr)) { Response.Write("<script language='javascript' type='text/javascript'> alert('删除失败,请重试或者检查网络联系管理员')</script>"); } workOut(); }
protected void yes_Click(object sender, EventArgs e) { string sqlStr = "SELECT * FROM k_ProductType WHERE Tp_company='" + Session["company"] + "' and Tp_name='" + ComTp.Text + "'"; DbSql ds = new DbSql(); DataTable da = new DataTable(); da = ds.FillDt(sqlStr); if (da.Rows.Count > 0) { Response.Write("<script language='javascript' type='text/javascript'> alert('添加失败,该类型已存在')</script>"); return; } sqlStr = "INSERT INTO k_ProductType (Tp_name, Tp_type,Tp_company) VALUES ('" + ComTp.Text + "', '零件','" + Session["company"] + "')"; if (!ds.ExecSql(sqlStr)) { Response.Write("<script language='javascript' type='text/javascript'> alert('添加失败,请重试或者检查网络联系管理员')</script>"); } workOut(); }
private int addCompany(Data data) { //返回1代表该公司已存在,返回2代表添加成功,返回0代表数据库添加失败 string sqlStr = "SELECT * FROM K_info_Company WHERE Co_company='" + data.company + "' and Co_abbreviation='" + data.abbreviation + "'"; DbSql ds = new DbSql(); DataTable da = new DataTable(); da = ds.FillDt(sqlStr); if (da.Rows.Count > 0) { return(1); } sqlStr = "INSERT INTO K_info_Company (Co_abbreviation, Co_name, Co_phone, Co_email, Co_address, Co_englishName,Co_company) VALUES ('" + data.abbreviation + "', '" + data.name + "', '" + data.phone + "', '" + data.email + "', '" + data.address + "','" + data.en_name + "','" + data.company + "')"; if (!ds.ExecSql(sqlStr)) { return(0); } return(2); }
private int addComponent(Data data) { //返回1代表该零件已存在,返回2代表添加成功,返回0代表数据库添加失败 string sqlStr = "SELECT * FROM K_Product WHERE Pd_company='" + data.company + "' Pd_id='" + data.Pd_id + "'"; DbSql ds = new DbSql(); DataTable da = new DataTable(); da = ds.FillDt(sqlStr); if (da.Rows.Count > 0) { return(1); } sqlStr = "INSERT INTO K_Product (Pd_typeId, Pd_manufacturerId, Pd_parameter, Pd_name, Pd_id, Pd_remarks,Pd_company) VALUES ('" + data.Pd_typeId + "', '" + data.Pd_manufacturerId + "', '" + data.Pd_parameter + "', '" + data.Pd_name + "', '" + data.Pd_id + "', '" + data.Pd_remarks + "', '" + data.company + "')"; if (!ds.ExecSql(sqlStr)) { return(0); } return(2); }
private string checkOut(Data data) { string sqlStr = " insert into K_Outlay (Ol_payDate,Ol_payee,Ol_payMethod,Ol_money,Ol_content,Ol_operator,Ol_remarks,Ol_company,Ol_editDate,Ol_state) values ('" + data.Ol_payDate + "','" + data.Ol_payee + "','" + data.Ol_payMethod + "','" + data.Ol_money + "','" + data.Ol_content + "','" + data.Ol_operator + "','" + data.Ol_remarks + "','" + data.Ol_company + "','" + data.Ol_editDate + "','" + data.Ol_state + "')"; float money = float.Parse(data.Pa_money) - float.Parse(data.Ol_money); if (money == 0) { sqlStr += " update K_Outlay set Ol_isValid='0' where Ol_id='" + data.Ol_id + "'"; } else { sqlStr += " update K_Outlay set Ol_money='" + money + "',Ol_editDate='" + data.Ol_editDate + "' where Ol_id='" + data.Ol_id + "'"; } DbSql ds = new DbSql(); if (ds.ExecSql(sqlStr)) { return("2"); //成功 } return("0"); //失败 }
private string checkOut(Data data) { string sqlStr = " insert into K_Income (Ic_payDate,Ic_payer,Ic_payMethod,Ic_money,Ic_content,Ic_operator,Ic_remarks,Ic_company,Ic_editDate,Ic_state) values ('" + data.Ic_payDate + "','" + data.Ic_payer + "','" + data.Ic_payMethod + "','" + data.Ic_money + "','" + data.Ic_content + "','" + data.Ic_operator + "','" + data.Ic_remarks + "','" + data.Ic_company + "','" + data.Ic_editDate + "','" + data.Ic_state + "')"; float money = float.Parse(data.Ra_money) - float.Parse(data.Ic_money); if (money == 0) { sqlStr += " update K_Income set Ic_isValid='0' where Ic_id='" + data.Ic_id + "'"; } else { sqlStr += " update K_Income set Ic_money='" + money + "',Ic_editDate='" + data.Ic_editDate + "' where Ic_id='" + data.Ic_id + "'"; } DbSql ds = new DbSql(); if (ds.ExecSql(sqlStr)) { return("2"); //成功 } return("0"); //失败 }
private int addComponent(Data data) { //返回1代表该SKU已存在,返回2代表添加成功,返回0代表数据库添加失败 string sqlStr = "SELECT * FROM K_ProductSku WHERE SKU_id='" + data.SKU_id + "'"; DbSql ds = new DbSql(); DataTable da = new DataTable(); da = ds.FillDt(sqlStr); if (da.Rows.Count > 0) { return(1); } sqlStr = "INSERT INTO K_ProductSku (SKU_inventory, SKU_pdId, SKU_parameter, SKU_name, SKU_id, SKU_remarks, SKU_price) VALUES ('" + data.SKU_inventory + "', '" + data.SKU_pdId + "', '" + data.SKU_parameter + "', '" + data.SKU_name + "', '" + data.SKU_id + "', '" + data.SKU_remarks + "', '" + data.SKU_price + "')"; if (!ds.ExecSql(sqlStr)) { return(0); } updateProduct(data.SKU_pdId); return(2); }
private void Check() { DateTime now = DateTime.Now; string today = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day; //先将本日本人的信息查询出来,如果不存在则新插入并返回当日考勤数据信息 string sqlStr = "select * from K_onoffDutyData where O_employeeId='" + Session["yhm"] + "' and O_checkDate='" + today + "'"; DbSql ds = new DbSql(); DataTable da = new DataTable(); da = ds.FillDt(sqlStr); if (da.Rows.Count == 0) { sqlStr = "insert into K_onoffDutyData(O_id,O_employeeId,O_checkDate) values('" + Guid.NewGuid() + "','" + Session["yhm"] + "','" + today + "')" + ";" + sqlStr; da = ds.FillDt(sqlStr); } DateTime tempTime = new DateTime(now.Year, now.Month, now.Day, 10, 0, 0); //判断十分钟内是否重复打卡 if (!noMoreCheckIn(da)) { tips("十分钟之内不允许重复打卡"); } //上午10点前第一次打卡上班 if (now < tempTime) { if (da.Rows[0]["O_onDuty1"].ToString() == "") { sqlStr = "update K_onoffDutyData set O_onDuty1 = '" + now + "' where O_id= '" + da.Rows[0]["O_id"] + "'"; if (!ds.ExecSql(sqlStr)) { tips("打卡错误,请重试或联系系统管理员"); return; } tips("上班打卡成功,打卡时间:" + now.ToString()); } else { tips("您已打卡,10点前早退则上午工时无效"); } return; } //上午10点前第一次打卡上班 tempTime = tempTime.AddMinutes(150); if (now < tempTime) { if (da.Rows[0]["O_offDuty1"].ToString() == "") { sqlStr = "update K_onoffDutyData set O_offDuty1 = '" + now + "' where O_id= '" + da.Rows[0]["O_id"] + "'"; if (!ds.ExecSql(sqlStr)) { tips("打卡错误,请重试或联系系统管理员"); return; } } else { tips("您已打卡,无法重复打卡;下午上班打卡12:30开始"); } if (da.Rows[0]["O_onDuty1"].ToString() == "") { tips("打卡成功,打卡结果您已严重迟到"); } else { tips("下班打卡成功,打卡时间:" + now.ToString()); } return; } //下午上班打卡 tempTime = tempTime.AddMinutes(150); if (now < tempTime) { if (da.Rows[0]["O_onDuty2"].ToString() == "") { sqlStr = "update K_onoffDutyData set O_onDuty2 = '" + now + "' where O_id= '" + da.Rows[0]["O_id"] + "'"; if (!ds.ExecSql(sqlStr)) { tips("打卡错误,请重试或联系系统管理员"); return; } tips("上班打卡成功,打卡时间:" + now.ToString()); } else { tips("您已打卡,无法重复打卡;15:00前早退则下午工时无效"); } return; } //下午下班打卡 tempTime = tempTime.AddMinutes(240); if (now < tempTime) { if (da.Rows[0]["O_offDuty2"].ToString() == "") { sqlStr = "update K_onoffDutyData set O_offDuty2 = '" + now + "' where O_id= '" + da.Rows[0]["O_id"] + "'"; if (!ds.ExecSql(sqlStr)) { tips("打卡错误,请重试或联系系统管理员"); return; } } else { tips("您已打卡,无法重复打卡;晚上加班打卡17:00开始"); } if (da.Rows[0]["O_onDuty2"].ToString() == "") { tips("打卡成功,打卡结果您已严重迟到"); } else { tips("下班打卡成功,打卡时间:" + now.ToString()); } return; } //晚班上班打卡 if (da.Rows[0]["O_onDuty3"].ToString() == "") { sqlStr = "update K_onoffDutyData set O_onDuty3 = '" + now + "' where O_id= '" + da.Rows[0]["O_id"] + "'"; if (!ds.ExecSql(sqlStr)) { tips("打卡错误,请重试或联系系统管理员"); return; } tips("晚班上班打卡成功,打卡时间:" + now.ToString()); return; } //晚班下班打卡 if (da.Rows[0]["O_offDuty3"].ToString() == "") { sqlStr = "update K_onoffDutyData set O_offDuty3 = '" + now + "' where O_id= '" + da.Rows[0]["O_id"] + "'"; if (!ds.ExecSql(sqlStr)) { tips("打卡错误,请重试或联系系统管理员"); return; } tips("今天工作已经完成,好好休息,明天继续努力,打卡时间:" + now.ToString()); return; } else { tips("今天工作已经完成,好好休息,明天继续努力"); } }