/// <summary> /// 用于更新sale00相应产品使用退货的功能 /// </summary> /// <param name="sale_id">销售单号</param> /// <param name="totmoney">总退货额</param> /// <param name="qty">总退货数量</param> /// <returns>bool</returns> public bool UpdateSale00(string sale_id, decimal totmoney, double qty) { bool a = false; DateTime datetime = DateTime.Now; try { string sql = "UPDATE sale00 SET BACK_SALES=" + totmoney + ", BACK_QUAN=" + qty + ", LAST_UPDATE='" + datetime + "' ,STATUS_ID='3',transfer_status='0' WHERE SALE_ID='" + sale_id + "'"; a = base.RunSQL(sql); } catch { string da = datetime.ToString("yyyy-MM-dd HH:mm:ss"); string sql = "UPDATE sale00 SET BACK_SALES=" + totmoney + ", BACK_QUAN=" + qty + ", LAST_UPDATE='" + da + "' ,STATUS_ID='3',transfer_status='0' WHERE SALE_ID='" + sale_id + "'"; a = base.RunSQL(sql); } if (a) { try { ReadIni readIni = new ReadIni("config.ini"); string srvIp = readIni.ReadString("RepastErp", "txtServerIP"); string srvPort = readIni.ReadString("RepastErp", "txtPort"); string srvDBName = readIni.ReadString("RepastErp", "txtIPdataname"); string srvUserName = readIni.ReadString("RepastErp", "txtFTPuser"); string srvPassword = readIni.ReadString("RepastErp", "txtFTPpassword"); string sql = "begin " + "UPDATE sale01 SET transfer_status='0' WHERE SALE_ID='" + sale_id + "';" + "UPDATE sale02 SET transfer_status='0' WHERE SALE_ID='" + sale_id + "';" + "delete from OPENDATASOURCE('SQLOLEDB','Data Source=" + srvIp + "," + srvPort + ";User ID=" + srvUserName + ";Password="******"' )." + srvDBName + ".dbo.sale00 where shop_id='" + Info.shop_id + "' and sale_id='" + sale_id + "';end"; DBSql.SRunSQL(sql); } catch { } } return(a); }
/// <summary> /// 删除临时表中符合要求的记录 /// </summary> public void DelSaletmp() { DBSql.SRunSQL("delete saletmp03 where sale_id in(select sale_id from saletmp00 where locked=0 and sale_id not in('" + Info.sale_id + "'))"); DBSql.SRunSQL("delete saletmp02 where sale_id in(select sale_id from saletmp00 where locked=0 and sale_id not in('" + Info.sale_id + "'))"); DBSql.SRunSQL("delete saletmp01 where sale_id in(select sale_id from saletmp00 where locked=0 and sale_id not in('" + Info.sale_id + "'))"); DBSql.SRunSQL("delete saletmp00 where locked=0 and sale_id not in('" + Info.sale_id + "')"); }
/// <summary> /// 按照要求删除本地数据库中的数据 /// </summary> /// <returns>成功删除返回true</returns> public bool DelLocalData() { DataSet ds = DBSql.SCreateDataSet("select * from pos_transfer where transfer_mode='out' or transfer_mode='shift'"); bool b = false; ReadIni readIni = new ReadIni("config.ini"); int day; try { day = Convert.ToInt32(mainForm.OperPara.GetIniConfig("clearDay")); if (day < 1) { day = 7; } } catch { day = 7; } DateTime d = DateTime.Now; string str; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { try { //SALE01中没有LAST_UPDATE字段且先执行SALE00的删除操作,再执行SALE01的删除操作 if (ds.Tables[0].Rows[i]["transfer_table"].ToString() == "SALE01") { continue; } else {//删除day天前的数据 str = " delete " + ds.Tables[0].Rows[i]["transfer_table"] + " where DATEDIFF(day,LAST_UPDATE,'" + d + "')>" + day; b = DBSql.SRunSQL(str); } } catch { b = false; } } str = " delete SALE01 where sale_id not in (select sale_id from sale00)"; b = DBSql.SRunSQL(str); str = " delete saletmp00 where DATEDIFF(day,LAST_UPDATE,'" + d + "')>" + day; b = DBSql.SRunSQL(str); str = " delete saletmp01 where sale_id not in (select sale_id from saletmp00)"; b = DBSql.SRunSQL(str); str = " delete saletmp02 where DATEDIFF(day,LAST_UPDATE,'" + d + "')>" + day; b = DBSql.SRunSQL(str); return(b); }
/// <summary> /// 如果满足条件,清空交班点时间 /// </summary> public void ClearTime() { //交班点 int timePoint; //上次上线时间 DateTime preLoginTime; //交班时间 DateTime changeWorkTime; //本次登录时间 DateTime nowLoginTime = DateTime.Now; try { preLoginTime = Convert.ToDateTime(readIni.ReadString("RepastErp", "preLoginTime")); //changeWorkTime = Convert.ToDateTime(readIni.ReadString("RepastErp", "changeWorkTime")); //timePoint = Convert.ToInt32(changeWorkTime.Hour); } catch { return; } //截取空格后的字符串 // string s1 = changeWorkTime.ToString(); //string s2 = s1.Substring(s1.IndexOf(" ") + 1); string s2 = readIni.ReadString("RepastErp", "changeWorkTime"); timePoint = Convert.ToInt32(s2.Substring(0, 2)); if (timePoint >= 0 && timePoint <= 6) { //截取空格前的字符串 string s3 = nowLoginTime.ToString(); string s4 = s3.Substring(0, s3.IndexOf(" ")); string s = s2 + " " + s4; //若交班时间是凌晨以后,则交班时间的年月日跟当前时间相同 changeWorkTime = Convert.ToDateTime(s); } else { //截取空格前的字符串 string s3 = preLoginTime.ToString(); string s4 = s3.Substring(0, s3.IndexOf(" ")); string s = s2 + " " + s4; //若交班时间是凌晨以前,则交班时间的年月日跟上次登录时间相同 changeWorkTime = Convert.ToDateTime(s); } //如第二次上线时间大于交班时间 if (DateTime.Compare(nowLoginTime, changeWorkTime) >= 0 && DateTime.Compare(changeWorkTime, preLoginTime) >= 0) { //清空配置文件config.ini中的班次 readIni.WriteString("RepastErp", "workNumber", "0"); //清空Info.ini配置文件中的交易号 ReadIni readIni1 = new ReadIni("Info.ini"); readIni1.WriteString("RepastErp", "deal_number", "1"); ReadIni readIniInfo = new ReadIni("Info.ini"); readIniInfo.WriteString("RepastErp", "isNormalOff", "true"); string oldSaleId = readIniInfo.ReadString("RepastErp", "sale_id"); try { DBSql.SRunSQL("delete saletmp00 where sale_id=" + oldSaleId + ""); DBSql.SRunSQL("delete saletmp01 where sale_id=" + oldSaleId + ""); DBSql.SRunSQL("delete saletmp02 where sale_id=" + oldSaleId + ""); } catch { } } }
/// <summary> /// 确定按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { string str = "select * from employee where emp_id =" + Info.emp_id; DataSet ds = DBSql.SCreateDataSet(str); if (ds != null && ds.Tables[0].Rows.Count > 0) { string md5PassDB = ds.Tables[0].Rows[0]["PASSWORD"].ToString(); string oldmd5PassInput = InfoToMD5(oldPassWord.Text); string newMD5Pass = InfoToMD5(newPassWord.Text); if (md5PassDB.Equals(oldmd5PassInput)) { if (newPassWord.Text.Equals(confirm.Text)) { if (newPassWord.Text.Trim() == "") { MessageBox.Show("密码不可为空", "消息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //往服务器中插入交班信息 ReadIni readIni = new ReadIni("config.ini"); string srvIp = readIni.ReadString("RepastErp", "txtServerIP"); string srvPort = readIni.ReadString("RepastErp", "txtPort"); string srvDBName = readIni.ReadString("RepastErp", "txtIPdataname"); string srvUserName = readIni.ReadString("RepastErp", "txtFTPuser"); string srvPassword = readIni.ReadString("RepastErp", "txtFTPpassword"); string sql = "update OPENDATASOURCE('SQLOLEDB','Data Source=" + srvIp + "," + srvPort + ";User ID=" + srvUserName + ";Password="******"' )." + srvDBName + ".dbo.employee set PASSWORD='******' where emp_id=" + Info.emp_id; string sql2 = "update employee set PASSWORD='******' where emp_id=" + Info.emp_id; bool b = DBSql.SRunSQL(sql2); b = DBSql.SRunSQL(sql); if (b) { MessageBox.Show("密码修改成功!"); } else { MessageBox.Show("密码修改失败!"); } oldPassWord.Text = ""; newPassWord.Text = ""; confirm.Text = ""; this.Dispose(); } else { MessageBox.Show("新密码与确认密码不一致!"); oldPassWord.Text = ""; newPassWord.Text = ""; confirm.Text = ""; } } else { MessageBox.Show("原始密码不正确!"); oldPassWord.Text = ""; newPassWord.Text = ""; confirm.Text = ""; } } else { MessageBox.Show("该用户不存在!"); } }