/// <summary> /// 是否可以改变数量 /// </summary> /// <param name="GROUP_PROD">组号</param> /// <param name="type">0代表在原来的基础上加一,1代表在原来的基础上减一,2代表把给定的字段改成给定的值num</param> /// <param name="sale_id">销售单号</param> /// <param name="num">数量</param> /// <returns></returns> public bool CanChangeQty(string GROUP_PROD, int type, string sale_id, decimal num) { string str = "select * from saletmp01 where GROUP_PROD=@group_prod and sale_id=@sale_id"; System.Data.SqlClient.SqlParameter[] para = new System.Data.SqlClient.SqlParameter[2]; para[0] = new System.Data.SqlClient.SqlParameter("@GROUP_PROD", SqlDbType.NVarChar); para[1] = new System.Data.SqlClient.SqlParameter("@SALE_ID", SqlDbType.NVarChar); para[0].Value = GROUP_PROD; para[1].Value = sale_id; //DataSet ds= DBSql.SCreateDataSet(str); DataSet ds = DBSql.SCreateDataSet(str, para); try { if (ds != null) { if (type == 0) { return(true); } else { decimal sale_price = Convert.ToDecimal(ds.Tables[0].Rows[0]["SALE_PRICE"]); decimal disc_total = -Convert.ToDecimal(ds.Tables[0].Rows[0]["ITEM_DISC_TOT"]); //2012年11月5日11:02:05 string price_type = ds.Tables[0].Rows[0]["PRICE_TYPE"].ToString(); int number = Convert.ToInt32(ds.Tables[0].Rows[0]["QTY"]); if (1 == type) { number -= 1; } else { number = Convert.ToInt32(num); } if (sale_price * number <= disc_total && price_type.Equals("2")) { return(false); } else { return(true); } } } else { return(false); } } catch { return(false); } }
/// <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> /// 根据用户名从服务器的pos_rounds表中获取登录有关的信息 /// </summary> /// <param name="userName">用户名</param> /// <returns>DataSet</returns> public DataSet GetOnlineInfo(string userName) { SqlParameter[] para = new SqlParameter[1]; para[0] = new SqlParameter("@USER_ID", SqlDbType.NVarChar); para[0].Value = userName; 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 str = " select * from OPENDATASOURCE('SQLOLEDB','Data Source=" + srvIp + "," + srvPort + ";User ID=" + srvUserName + ";Password="******"' )." + srvDBName + ".dbo.POS_ROUNDS where user_id=@USER_ID and exit_date is null"; return(DBSql.SCreateDataSet(str, para)); }
/// <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("该用户不存在!"); } }