private void WriteSumToGrid(string szDateCondition, ref int iBgnRow) { string szSql = "select '汇总',format(sum(prod_w - prod_nw) / 1000, 3)," + "format(sum(prod_amount) / 100, 2),format(sum(prod_amount) * 10 / sum(prod_w - prod_nw), 2)," + "format(sum(MKT_BUYER_FEE) / 100, 2), format(sum(MKT_SELLER_FEE) / 100, 2)," + "format(sum(YTB_BUYER_FEE) / 100, 2),format(sum(YTB_SELLER_FEE) / 100, 2), " + "format(sum(prod_amount + MKT_BUYER_FEE + MKT_SELLER_FEE + YTB_BUYER_FEE + YTB_SELLER_FEE) / 100, 2)" + "from rec_trade a,base_prod b where CANCEL_MARK='N' and a.PROD_ID = b.PROD_ID and b.PROD_LEVEL=1 and " + szDateCondition; string szErr = ""; DataSet ds = new DataSet(); int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询商品交易汇总记录", "SQL=" + szSql + ",Err=" + szErr); MyStart.oMyDb.Close(); return; } DataTable dt = ds.Tables[0]; //mDt = dt; int iCurNum = 1;// (iNum < miDefRows ? miDefRows : iNum); MyFunc.GridWriteDt(ref dataGridViewRst, ref dt, iBgnRow, miCols, ref iCurNum); iBgnRow++; }
private void button_Edit_Click(object sender, EventArgs e) { if (DialogResult.No == MessageBox.Show("确认修改持卡人信息吗?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return; } //连接银石后台 EbHttpClass objHttp = new EbHttpClass(); string szErr = ""; bool bRst = objHttp.ChgUserInf(textBox_Card.Text, textBox_Person.Text, textBox_Cell.Text, textBox_CertID.Text, ref szErr); if (!bRst) { MessageBox.Show("后台修改持卡人信息失败( " + szErr + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string szSql = "update base_ucard set user_name='" + textBox_Person.Text.Trim() + "',USER_TEL='" + textBox_Cell.Text.Trim() + "',CERT_ID='" + textBox_CertID.Text.Trim() + "',CHG_ID=" + MyStart.giUserID + ",user_addr='" + textBox_Addr.Text.Trim() + "',rmrk='" + textBox_rmrk.Text.Trim() + "', CHG_DT=curtime() where user_card='" + textBox_Card.Text.Trim() + "'"; DataSet ds = new DataSet(); szErr = ""; int iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); if (iRst < 1) { MessageBox.Show("修改持卡人信息出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("买方卡查询-修改", "SQL=" + szSql + ",Err=" + szErr); } MessageBox.Show("修改持卡人信息成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); button_Edit.Enabled = false; }
private void AddNewFee(string szTitle, string szProdID, string szProdName, string szRateType, string szRate, string szBgn, string szEnd) { string szSql = "INSERT INTO mng_rate (PROD_ID,RATE_TYPE,BGN_TIME,END_TIME,RATE,RATE_VALID,ADD_DT,ADD_ID,RMRK) VALUES (" + szProdID + "," + szRateType + ",'" + szBgn + " ','" + szEnd + "'," + szRate + ",'Y',curtime()," + MyStart.giUserID.ToString() + ",'" + textBox_Desc.Text + "')"; string szErr = ""; int iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); if (iRst < 1) { MessageBox.Show("保存出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr); } else { szSql = szProdName + "-" + textBox_Rate.Text + "% (" + szBgn + "," + szEnd + ")"; MyFunc.WriteToDbLog(szTitle, szSql, "MSG", MyStart.giUserID); //MessageBox.Show("保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); GridDataRefresh(); MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",OK"); } MyStart.oMyDb.Close(); return; }
public static void WriteToDbLog(string szTitle, string szInf, string szType, int iUserID) { try { string szLogSql = "INSERT INTO sys_log (LOG_RMRK,LOG_INFO,REC_TIME,LOG_LEVEL,LOG_USER) VALUES ("; string szErr = ""; int iRst; if (szInf.Length > 0) { szLogSql += "'" + szTitle + "','" + szInf + "',curtime(),'" + szType + "'," + iUserID + ")"; } else { szLogSql += "'" + szTitle + "','',curtime(),'" + szType + "'," + iUserID + ")"; } iRst = MyStart.oMyDb.WriteData(szLogSql, ref szErr); if (iRst < 1) { MessageBox.Show("写日志出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog(szTitle, "SQL=" + szLogSql + ",Err=" + szErr); //return; } } catch (Exception ex) { //MessageBox.Show("解挂卡片失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); string sz = ex.Message; } MyStart.oMyDb.Close(); }
private void button_Del_Click(object sender, EventArgs e) { DataGridViewRow oCurRow = dataGridView1.CurrentRow; if (oCurRow == null) { MessageBox.Show("请先选择要删除的分类信息", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (DialogResult.No == MessageBox.Show("请确认要删除该分类信息", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { MessageBox.Show("取消当前删除操作", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { string szSql = "select count(*) from base_prod where parent_id=" + mszCode; DataSet ds = new DataSet(); string szErr = ""; int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("删除操作出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("商品分类信息-删除", "SQL=" + szSql + ",Err=" + szErr); goto Eend; } int iNum = ds.Tables[0].Rows.Count; if (iNum != 1) { MessageBox.Show("删除操作出错(错误原因:selete count(*) error)", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("商品分类信息-删除", "SQL=" + szSql + ",Err=no record return"); goto Eend; } iNum = Convert.ToInt32(ds.Tables[0].Rows[0][0]); if (iNum > 0) { MessageBox.Show("该分类下有设置明细商品,请先清除对应的所有明细商品后,再删除当前商品分类操作", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); goto Eend; } szSql = "delete from base_prod where prod_id=" + mszCode; iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); if (iRst < 1) { MessageBox.Show("删除操作出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("商品分类信息-删除", "SQL=" + szSql + ",Err=" + szErr); goto Eend; } MessageBox.Show("删除该分类商品成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); GridDataRefresh(); } catch (Exception ex) { MessageBox.Show("删除该分类商品失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } Eend: MyStart.oMyDb.Close(); return; }
private void WriteDataToGrid(string szFirmName, string szFirmCard, string szDateCondition, ref int iBgnRow) { string szSql = "select '" + szFirmName + "',PROD_NAME,format(sum(prod_w - prod_nw) / 1000, 3)," + "format(sum(prod_amount) / 100, 2),format(sum(prod_amount) * 10 / sum(prod_w - prod_nw), 2)," + "format(sum(MKT_BUYER_FEE) / 100, 2), 0.00," //format(sum(MKT_SELLER_FEE) / 100, 2)," + "format(sum(YTB_BUYER_FEE + YTB_SELLER_FEE) / 100, 2), " //+ "format(sum(prod_amount + MKT_BUYER_FEE + MKT_SELLER_FEE + YTB_BUYER_FEE + YTB_SELLER_FEE) / 100, 2) " + "format(sum(prod_amount + MKT_BUYER_FEE + YTB_BUYER_FEE + YTB_SELLER_FEE) / 100, 2) " + "from rec_trade a,base_prod b " + "where a.CANCEL_MARK='N' and user_card in (" + szFirmCard + ") and a.PROD_ID = b.PROD_ID and b.PROD_LEVEL=1 and " + szDateCondition + " group by a.prod_id"; string szErr = ""; DataSet ds = new DataSet(); int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询买方交易记录", "SQL=" + szSql + ",Err=" + szErr); MyStart.oMyDb.Close(); return; } DataTable dt = ds.Tables[0]; int iNum = dt.Rows.Count; if (iNum == 0) { MyStart.oMyDb.Close(); return; } //mDt = dt; int iCurNum = (iNum < miDefRows ? miDefRows : iNum); MyFunc.GridWriteDt(ref dataGridViewRst, ref dt, iBgnRow, miCols, ref iCurNum); iBgnRow += iNum; szSql = "select ' ','汇总',format(sum(prod_w - prod_nw) / 1000, 3)," + "format(sum(prod_amount) / 100, 2),format(sum(prod_amount) * 10 / sum(prod_w - prod_nw), 2)," + "format(sum(MKT_BUYER_FEE) / 100, 2),0.00," // format(sum(MKT_SELLER_FEE) / 100, 2)," + "format(sum(YTB_BUYER_FEE + YTB_SELLER_FEE) / 100, 2), " //+ "format(sum(prod_amount + MKT_BUYER_FEE + MKT_SELLER_FEE + YTB_BUYER_FEE + YTB_SELLER_FEE) / 100, 2)" + "format(sum(prod_amount + MKT_BUYER_FEE + YTB_BUYER_FEE + YTB_SELLER_FEE) / 100, 2)" + "from rec_trade where CANCEL_MARK='N' and user_card in (" + szFirmCard + ") and PROD_ID>0 and " + szDateCondition; iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询买方交易汇总记录", "SQL=" + szSql + ",Err=" + szErr); MyStart.oMyDb.Close(); return; } dt = ds.Tables[0]; //mDt = dt; iCurNum = 1;// (iNum < miDefRows ? miDefRows : iNum); MyFunc.GridWriteDt(ref dataGridViewRst, ref dt, iBgnRow, miCols, ref iCurNum); iBgnRow++; MyStart.oMyDb.Close(); }
private void frm_Card_AddVal_Load(object sender, EventArgs e) { this.Icon = new Icon(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.add.ico")); //pictureBox1.Image = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.ie4power.ico")); button_CheckCard.Image = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.preview.ico")); button_AddValue.Image = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.add.ico")); button_Print.Image = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.print.ico")); button_Retry.Image = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.Undo.ico")); button_Exit.Image = Image.FromStream(frm_Main.oResource.GetManifestResourceStream(frm_Main.szProjName + ".Pict.exit01.ico")); if (mszFlag.ToUpper() == "USER_CARD") { this.Text = "买方卡充值"; } else if (mszFlag.ToUpper() == "FIRM_CARD") { this.Text = "卖方卡充值"; } else { this.Text = "卡片充值"; } comboBox_Type.Items.Clear(); string szSql = "select sub_type from base_value where type=1 order by id"; string szErr = ""; DataSet ds = new DataSet(); int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询充值类型失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询充值类型失败", "SQL=" + szSql + ",Err=" + szErr); MyStart.oMyDb.Close(); return; } int iNum = ds.Tables[0].Rows.Count; int SeleCash = 0; if (iNum > 0) { for (int i = 0; i < iNum; i++) { DataRow dr = ds.Tables[0].Rows[i]; comboBox_Type.Items.Add(dr[0].ToString()); if (dr[0].ToString() == "现金") { SeleCash = i; } } comboBox_Type.SelectedIndex = SeleCash; } NewAdd(); button_Retry.Enabled = false; button_CheckCard.Focus(); }
private void button_Save_Click(object sender, EventArgs e) { string szKeyName = label_KeyName.Text.Trim();// .Substring(1, 2); int iKeyName = Convert.ToInt16(szKeyName.Substring(1)); string[] szX = comboBox_ProdList.Text.Split('-'); string szSql = "select * from base_keys where func_name='" + szX[0] + "' and key_name <> '" + szKeyName + "'"; try { DataSet ds = new DataSet(); string szErr = ""; int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MyIniFile.WriteLog("定义快捷键-查找商品快捷键的信息", "SQL=" + szSql + ",Err=" + szErr); MessageBox.Show("查询商品快捷键信息失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); goto Eend; } if (ds.Tables[0].Rows.Count > 0) { MyIniFile.WriteLog("定义快捷键-查找商品快捷键的信息", "SQL=" + szSql + ",Err=已定义该商品的快捷键"); if (DialogResult.No == MessageBox.Show("已定义了该商品的快捷键,是否重复定义?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { goto Eend; } } if (label_ProdName.Text.Length == 0)//new, need insert { szSql = "INSERT INTO base_keys(USER_ID,KEY_NAME,KEY_TYPE,FUNC_NAME) VALUES (0,'" + szKeyName + "',2,'" + szX[0] + "')"; } else//old,need update { szSql = "UPDATE base_keys SET FUNC_NAME = '" + szX[0] + "' WHERE KEY_NAME = '" + szKeyName + "'"; } iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); if (iRst < 1) { MyIniFile.WriteLog("定义快捷键-保存商品快捷键的信息", "SQL=" + szSql + ",Err=" + szErr); MessageBox.Show("保存商品快捷键失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); goto Eend; } MessageBox.Show("保存商品快捷键成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); ArrayProcID[iKeyName - 1] = szX[0]; ArrayProcName[iKeyName - 1] = szX[1]; label_ProdName.Text = szX[1]; SetButton(iKeyName - 1); } catch (Exception ex) { MessageBox.Show("保存商品快捷键失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } Eend: MyStart.oMyDb.Close(); }
private void button_Del_Click(object sender, EventArgs e) { DataGridViewRow oCurRow = dataGridView1.CurrentRow; if (oCurRow == null) { MessageBox.Show("请先选择要删除的卖方信息", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (DialogResult.No == MessageBox.Show("请确认要删除该卖方信息", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { MessageBox.Show("取消当前删除操作", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string szSql = "select count(*) from base_store where STORE_ID=" + mszCode; try { DataSet ds = new DataSet(); string szErr = ""; int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("删除操作出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("卖方基本信息-删除", "SQL=" + szSql + ",Err=" + szErr); goto Eend; } int iNum = ds.Tables[0].Rows.Count; if (iNum != 1) { MessageBox.Show("删除操作出错(错误原因:selete count(*) error)", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("卖方基本信息-删除", "SQL=" + szSql + ",Err=no record return"); goto Eend; } szSql = "update base_store set STORE_STAT='STOP' where STORE_ID=" + mszCode; iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); if (iRst < 1) { MessageBox.Show("删除操作出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("卖方基本信息-删除", "SQL=" + szSql + ",Err=" + szErr); goto Eend; } MessageBox.Show("删除该卖方成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); GridDataRefresh(); } catch (Exception ex) { MessageBox.Show("删除该卖方失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } Eend: MyStart.oMyDb.Close(); return; }
private void button_Qry_Click(object sender, EventArgs e) { MyFunc.WriteToDbLog("查询工作日志", "", "MSG", MyStart.giUserID); string szBgn = string.Format("{0:yyyy-MM-dd}", dateTimePicker_Bgn.Value) + " 00:00:00"; string szEnd = string.Format("{0:yyyy-MM-dd}", dateTimePicker_End.Value) + " 23:59:59"; dataGridViewRst.Rows.Clear(); MyFunc.GridInit(ref dataGridViewRst, mszTitle, mszTitleWidth, 15, miDefRows, true); try { DataSet ds = new DataSet(); string szSql = "select user_name,rec_time,log_rmrk,log_info from sys_log a,sys_users b " + "where a.LOG_USER = b.USER_ID and user_type>1 "; if (comboBox_User.SelectedIndex > 0) { string[] szX = comboBox_User.Text.Split('-'); szSql += " and a.LOG_USER = "******" and rec_time>='" + szBgn + "' and rec_time<='" + szEnd + "' order by a.LOG_USER,rec_time desc"; string szErr = ""; int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询操作日志", "SQL=" + szSql + ",Err=" + szErr); goto Eend; } DataTable dt = ds.Tables[0]; mDt = dt; int iNum = dt.Rows.Count; if (iNum == 0) { MessageBox.Show("没有数据", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); goto Eend; } int iCurNum = (iNum < miDefRows ? miDefRows : iNum); MyFunc.GridWriteDt(ref dataGridViewRst, ref dt, 0, miCols, ref iCurNum); miRows = iNum; mszRptDate = string.Format("{0:yyyy-MM-dd}", dateTimePicker_Bgn.Value) + " 至 " + string.Format("{0:yyyy-MM-dd}", dateTimePicker_End.Value); button_Rpt.Enabled = true; } catch (Exception ex) { MessageBox.Show("查询操作日志失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } Eend: MyStart.oMyDb.Close(); }
private string Get_STORE_CARD(string szFirmID, string szRentID) { string szFirmCard = ""; string szSql; if (szRentID.Length > 0) { szSql = "select STORE_CARD from mng_card where CARD_TYPE =2 and STORE_ID = " + szFirmID + " and STALL_ID=" + szRentID; } else { szSql = "select STORE_CARD from mng_card where CARD_TYPE<4 and STORE_ID = " + szFirmID; } string szErr = ""; try { DataSet ds = new DataSet(); int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询卖方卡信息", "SQL=" + szSql + ",Err=" + szErr); goto Eend; } int iNum = ds.Tables[0].Rows.Count; szFirmCard = ""; DataRow dr; if (iNum > 0) { for (int j = 0; j < iNum - 1; j++) { dr = ds.Tables[0].Rows[j]; szFirmCard += dr[0].ToString() + ","; } dr = ds.Tables[0].Rows[iNum - 1]; szFirmCard += dr[0].ToString(); } } catch (Exception ex) { MessageBox.Show("查询卖方卡信息失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } Eend: MyStart.oMyDb.Close(); return(szFirmCard); }
private void EditNewFee(string szTitle, string szProdID, string szProdName, string szRateType, string szRate, string szBgn, string szEnd) { string szSql = "INSERT INTO mng_rate_his (PROD_ID,RATE_TYPE,BGN_TIME,END_TIME,RATE,RATE_VALID,ADD_DT,ADD_ID,RMRK) VALUES (" + szProdID + "," + szRateType + ",'" + mszBgn + "','" + string.Format("{0:yyyy-MM-dd}", dateTimePicker_Bgn.Value.AddDays(-1)) + " 23:59:59'," + szRate + ",'N',curtime()," + MyStart.giUserID.ToString() + ",'" + mszInf + "')"; string szErr = ""; int iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); if (iRst < 1) { MessageBox.Show("保存修改后的信息出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr); MyStart.oMyDb.Close(); return; } szSql = "UPDATE mng_rate SET BGN_TIME='" + szBgn + "',END_TIME = '" + szEnd + " ',RATE = " + (Convert.ToSingle(textBox_Rate.Text) * 10).ToString() + ",CHG_DT = curtime()" + ",CHG_ID = " + MyStart.giUserID.ToString() + ",RMRK = '" + textBox_Desc.Text + "' where prod_id=" + mszCode + " and rate_type=" + szRateType; iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); if (iRst < 1) { MessageBox.Show("保存出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr); } else { szSql = szProdName + "-" + textBox_Rate.Text + "% (" + szBgn + "," + szEnd + ")"; MyFunc.WriteToDbLog(szTitle, szSql, "MSG", MyStart.giUserID); //MessageBox.Show("保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); GridDataRefresh(); MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",OK"); } MyStart.oMyDb.Close(); return; }
private void WriteSumToGrid(string szDateCondition, ref int iBgnRow) { //string szSql = "select '汇总',format(sum(prod_w - prod_nw) / 1000, 3)," // + "format(sum(prod_amount) / 100, 2),format(sum(prod_amount) * 10 / sum(prod_w - prod_nw), 2)," // + "format(sum(MKT_BUYER_FEE) / 100, 2), format(sum(MKT_SELLER_FEE) / 100, 2)," // + "format(sum(YTB_BUYER_FEE + YTB_SELLER_FEE) / 100, 2), " // + "format(sum(prod_amount + MKT_BUYER_FEE + MKT_SELLER_FEE + YTB_BUYER_FEE + YTB_SELLER_FEE) / 100, 2)" // + "from rec_trade where " + szDateCondition; string szSql = "select '汇总',format(sum(prod_w) / 1000, 3),format(sum(prod_nw) / 1000, 3)," + "format(sum(prod_w - prod_nw) / 1000, 3)," + "format(sum(prod_amount)*10 / sum(prod_w - prod_nw),2),format(sum(prod_amount) / 100, 2), " + "format(sum(MKT_BUYER_FEE + MKT_SELLER_FEE + YTB_BUYER_FEE + YTB_SELLER_FEE) / 100,2) " + "from rec_trade a,sys_users b " + "where a.USER_ID2 = b.USER_ID and a.CANCEL_MARK='N' and a.PROD_ID>0 and " + szDateCondition; if (comboBox_dpt.SelectedIndex > 0) { if (comboBox_Firm.SelectedIndex == 0) { szSql += " and b.USER_DPT='" + comboBox_dpt.Text.Trim() + "'"; } } string szErr = ""; DataSet ds = new DataSet(); int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询磅房交易汇总记录", "SQL=" + szSql + ",Err=" + szErr); MyStart.oMyDb.Close(); return; } DataTable dt = ds.Tables[0]; //mDt = dt; int iCurNum = 1;// (iNum < miDefRows ? miDefRows : iNum); MyFunc.GridWriteDt(ref dataGridViewRst, ref dt, iBgnRow, miCols, ref iCurNum); iBgnRow++; }
private void button_Save_Click(object sender, EventArgs e) { string szTitle = "人员权限管理"; string szApp = GetApp(); string szSql = "UPDATE sys_users SET USER_APP = '" + szApp + "',RMRK = '" + textBox_Desc.Text.Trim() + "'"; if (checkBox_Pos.Checked)//pos { szSql += ", USER_TYPE=3"; } szSql += " WHERE USER_ID=" + textBox_Code.Text.Trim(); string szErr = ""; try { int iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); if (iRst < 1) { MessageBox.Show("保存出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr); } else { szSql = "编号" + mszCode + "-姓名" + mszName + "-权限" + szApp; MyFunc.WriteToDbLog(szTitle, szSql, "MSG", MyStart.giUserID); MessageBox.Show("保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); GridDataRefresh(); MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",OK"); } groupBoxInf.Enabled = false; groupBoxList.Enabled = true; } catch (Exception ex) { MessageBox.Show("保存失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } MyStart.oMyDb.Close(); }
private void button_Save_Click(object sender, EventArgs e) { if (textBox_Old_Pwd.Text.Trim().ToUpper().CompareTo(MyStart.gszUserPwd.ToUpper()) != 0) { MessageBox.Show("旧密码错误!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_Old_Pwd.Focus(); return; } if (textBox_New_Pwd.Text.CompareTo(textBox_2nd_Pwd.Text) != 0) { MessageBox.Show("两次输入的新密码错误!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_New_Pwd.Focus(); return; } string szNewPwd = MyTools.OpenString_To_HideString((textBox_New_Pwd.Text + " ").Substring(0, 8), MyStart.gszPwdKey); string szSql = "UPDATE sys_users SET USER_PWD = '" + szNewPwd + "' WHERE USER_ID=" + MyStart.giUserID; string szErr = ""; try { int iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); if (iRst < 1) { MessageBox.Show("更改密码失败(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("当班人员-更改密码", "SQL=" + szSql + ",Err=" + szErr); } } catch (Exception ex) { MessageBox.Show("更改密码失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } MyStart.oMyDb.Close(); MyFunc.WriteToDbLog("当班人员-更改密码", "", "MSG", MyStart.giUserID); MessageBox.Show("更改密码成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void WriteDataToGrid(string szFirm, string szFirmCard, string szDateCondition, ref int iBgnRow, ref int iCardNum, ref bool HasCard) { HasCard = false; string szSql = "(SELECT '" + szFirm + "' as 卖方名称,a.ADD_DT as 发卡时间, " + "if (CARD_TYPE = 1,'第一副卡',if (CARD_TYPE = 2,'副卡','结算卡')) as 卡类,STORE_CARD as 卡号, " + "if (CARD_STAT = 'BGN','正常',if (CARD_STAT = 'STOP','无效','挂失')) as 状态,STALL_INF as 档口信息, " + "STORE_PERSON as 联系人,a.USER_TEL as 联系电话, a.cert_id as 身份证, b.USER_NAME as 开卡人 " + "FROM mng_card a,sys_users b where a.ADD_ID=b.USER_ID and STORE_CARD in( " + szFirmCard + ") order by a.ADD_DT) " + "union " + "(select '小计', '', '', count(*), '','', '', '', '', '' from mng_card where STORE_CARD in( " + szFirmCard + "))"; string szErr = ""; DataSet ds = new DataSet(); int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询发卖方卡", "SQL=" + szSql + ",Err=" + szErr); MyStart.oMyDb.Close(); return; } DataTable dt = ds.Tables[0]; int iNum = dt.Rows.Count; if (iNum == 1) { MyStart.oMyDb.Close(); return; } //mDt = dt; iCardNum = iNum - 1; int iCurNum = (iNum < miDefRows ? miDefRows :iNum); MyFunc.GridWriteDt(ref dataGridView_Detail, ref dt, iBgnRow, miCols, ref iCurNum); iBgnRow += iNum; HasCard = true; MyStart.oMyDb.Close(); }
private string Get_STORE_CARD(string szFirmID, string szRentID) { string szFirmCard = ""; //string szSql = "select STORE_CARD from mng_card a,base_stall b " // + "where CARD_TYPE<3 and a.STORE_ID = b.STORE_ID and STALL_STAT='USED' and b.STORE_ID = " + szFirmID; string szSql = "select STORE_CARD from mng_card where CARD_TYPE<3 and STORE_ID = " + szFirmID; if (szRentID.Length > 0) { szSql += " and STALL_ID=" + szRentID; } string szErr = ""; DataSet ds = new DataSet(); int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询卖方卡信息", "SQL=" + szSql + ",Err=" + szErr); return(szFirmCard); } int iNum = ds.Tables[0].Rows.Count; szFirmCard = ""; DataRow dr; if (iNum > 0) { for (int j = 0; j < iNum - 1; j++) { dr = ds.Tables[0].Rows[j]; szFirmCard += dr[0].ToString() + ","; } dr = ds.Tables[0].Rows[iNum - 1]; szFirmCard += dr[0].ToString(); } return(szFirmCard); }
private void button_Del_Click(object sender, EventArgs e) { DataGridViewRow oCurRow = dataGridView1.CurrentRow; if (oCurRow == null) { MessageBox.Show("请先选择要删除的商品信息", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (DialogResult.No == MessageBox.Show("请确认要删除该商品信息", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { MessageBox.Show("取消当前删除操作", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string szSql = "delete from base_prod where prod_id=" + mszCode; string szErr = ""; try { int iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); if (iRst < 1) { MessageBox.Show("删除操作出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("商品基本信息-删除", "SQL=" + szSql + ",Err=" + szErr); return; } MessageBox.Show("删除该商品成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); GridDataRefresh(); } catch (Exception ex) { MessageBox.Show("删除该商品失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } MyStart.oMyDb.Close(); }
private void button_Qry_Click(object sender, EventArgs e) { string szCard = textBox_Card.Text; if (szCard.Length == 15) { szCard = MyStart.gszCardFirmFirst + textBox_Card.Text; } MyFunc.WriteToDbLog("刷卡查询销售明细", "", "MSG", MyStart.giUserID); dataGridViewRst.Rows.Clear(); MyFunc.GridInit(ref dataGridViewRst, mszTitle, mszTitleWidth, 15, miDefRows, true); if (MyStart.gszMrktName.Length > 0) { mszRptTitle = MyStart.gszMrktName + "销售明细表"; } else { mszRptTitle = "销售明细表"; } DataSet ds = new DataSet(); string szWhere = ""; string szDetailSql = "select a.sys_id,jy_tim,substring(a.store_card,2),user_card,prod_name,format(prod_up / 100, 2)," + "format(prod_w / 1000, 3),format(prod_nw / 1000, 3)," + "format((prod_w - prod_nw) / 1000, 3),format(prod_amount / 100, 2), " + "concat(format(MKT_BUYER_FEE_RATE/10,1),'%'),format(MKT_BUYER_FEE/ 100, 2), " + "concat(format(MKT_SELLER_FEE_RATE/10,1),'%'),format(MKT_SELLER_FEE/ 100, 2)," + "concat(format(YTB_BUYER_FEE_RATE/10,1),'%'),format(YTB_BUYER_FEE/ 100, 2), " + "concat(format(YTB_SELLER_FEE_RATE/10,1),'%'),format(YTB_SELLER_FEE/ 100, 2)," /*+ "concat(format((YTB_BUYER_FEE_RATE+YTB_SELLER_FEE_RATE)/10,1),'%')," + "format((YTB_BUYER_FEE + YTB_SELLER_FEE)/ 100, 2), "*/ + "format((prod_amount + MKT_BUYER_FEE + MKT_SELLER_FEE + YTB_BUYER_FEE + YTB_SELLER_FEE)/ 100, 2)"; mszSumSql = "select '合计','-','-','-','-','-'," + "format(sum(prod_w) / 1000, 3),format(sum(prod_nw) / 1000, 3)," + "format(sum(prod_w - prod_nw) / 1000, 3),format(sum(prod_amount) / 100, 2), " + "'-',format(sum(MKT_BUYER_FEE)/ 100, 2), " + "'-',format(sum(MKT_SELLER_FEE)/ 100, 2)," + "'-',format(sum(YTB_BUYER_FEE)/ 100, 2), " + "'-',format(sum(YTB_SELLER_FEE)/ 100, 2), " + "format(sum(prod_amount + MKT_BUYER_FEE + MKT_SELLER_FEE + YTB_BUYER_FEE + YTB_SELLER_FEE)/ 100, 2)"; szWhere = " from rec_trade a, base_prod b,mng_card c,base_store e,sys_msg f " + " where a.CANCEL_MARK='N' and a.STORE_CARD=c.STORE_CARD and c.STORE_ID=e.STORE_ID" + " and a.PROD_ID = b.PROD_ID and b.PROD_LEVEL=1 and a.MSG_ID=f.MSG_ID"; szWhere += " and jy_tim>='" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_Bgn.Value) + "' "; // + " 00:00:00' "; szWhere += " and jy_tim<='" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_End.Value) + "' "; // + " 23:59:59' "; //szWhere += " and jy_tim>='" + string.Format("{0:yyyy-MM-dd}", dateTimePicker_Bgn.Value) + " 00:00:00' "; //szWhere += " and jy_tim<='" + string.Format("{0:yyyy-MM-dd}", dateTimePicker_End.Value) + " 23:59:59' "; //验卡 string szSql = "select user_card from base_ucard where user_card='" + szCard + "'"; string szErr = ""; try { int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("卡片查询失败,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("刷卡查询商品交易明细信息", "SQL=" + szSql + ",Err=" + szErr); goto Eend; } int iNum = ds.Tables[0].Rows.Count; if (iNum > 0)//买方卡 { if (DialogResult.No == MessageBox.Show("是否查询买方卡" + szCard + "的交易明细?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { goto Eend; } szWhere += " and a.user_card='" + szCard + "' "; } else { szSql = "select a.STORE_ID,CARD_TYPE,STORE_NAME from mng_card a,base_store b " + "where a.STORE_ID=b.STORE_ID and STORE_CARD = '" + szCard + "'"; iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("卡片查询失败,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("刷卡查询商品交易明细信息", "SQL=" + szSql + ",Err=" + szErr); goto Eend; } iNum = ds.Tables[0].Rows.Count; if (iNum == 0) { MessageBox.Show("系统中无此卡号,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("刷卡查询商品交易明细信息", "SQL=" + szSql + ",Err=系统中无此卡号"); goto Eend; } if (iNum > 1) { MessageBox.Show("系统中卡号重复记录,请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("刷卡查询商品交易明细信息", "SQL=" + szSql + ",Err=系统中卡号重复记录"); goto Eend; } DataRow dr = ds.Tables[0].Rows[0]; int iFirmID = Convert.ToInt16(dr[0]); int iCardType = Convert.ToInt16(dr[1]); string szFirmName = dr[2].ToString(); if (iCardType == 2)//副卡 { if (DialogResult.No == MessageBox.Show("是否查询卖方副卡" + textBox_Card.Text + "的交易明细?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { goto Eend; } szWhere += " and a.STORE_CARD='" + szCard + "' "; } else { szSql = "select STORE_CARD from mng_card where STORE_ID=" + iFirmID + " and CARD_TYPE<3"; iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询卖方副卡失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询卖方副卡信息", "SQL=" + szSql + ",Err=" + szErr); goto Eend; } iNum = ds.Tables[0].Rows.Count; szCard = ""; if (iNum > 0) { if (DialogResult.No == MessageBox.Show("是否查询卖方(" + szFirmName + ")的交易明细?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { goto Eend; } szCard = ""; for (int i = 0; i < iNum; i++) { dr = ds.Tables[0].Rows[i]; szCard += "'" + dr[0].ToString() + "'"; if ((i + 1) < iNum) { szCard += ","; } } } szWhere += " and a.STORE_CARD in (" + szCard + ") "; } } szDetailSql = szDetailSql + szWhere + " order by jy_tim desc"; if (mszSumSql.Length > 0) { mszSumSql += szWhere; } iRst = MyStart.oMyDb.ReadData(szDetailSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询商品交易明细信息", "SQL=" + szDetailSql + ",Err=" + szErr); goto Eend; } DataTable dt = ds.Tables[0]; mDt = dt; iNum = dt.Rows.Count; if (iNum == 0) { MessageBox.Show("没有数据", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); goto Eend; } int iCurNum = (iNum < miDefRows ? miDefRows : iNum); MyFunc.GridWriteDt(ref dataGridViewRst, ref dt, 0, miCols, ref iCurNum); miRows = iNum; mszRptDate = string.Format("{0:yyyy-MM-dd}", dateTimePicker_Bgn.Value) + " 至 " + string.Format("{0:yyyy-MM-dd}", dateTimePicker_End.Value); button_Rpt.Enabled = true; } catch (Exception ex) { MessageBox.Show("查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } Eend: MyStart.oMyDb.Close(); }
private void button_Save_Click(object sender, EventArgs e) { if (DialogResult.No == MessageBox.Show("请确认要保存该分类信息", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { MessageBox.Show("取消当前保存操作", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string szSql; string szTitle; if (textBox_Code.Enabled)//add { bool bSameID = false; int iNum = dataGridView1.Rows.Count; for (int i = 0; i < iNum; i++) { if (dataGridView1.Rows[i].Cells[0].Value != null) { if (dataGridView1.Rows[i].Cells[0].Value.ToString() == textBox_Code.Text.Trim()) { bSameID = true; break; } } } if (bSameID) { MessageBox.Show("商品的分类编号不能重复,请重新设置", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_Code.SelectAll(); textBox_Code.Focus(); return; } szTitle = "商品分类信息-新增"; szSql = "INSERT INTO base_prod(PROD_ID,PROD_NAME,PROD_LEVEL) VALUES(" + textBox_Code.Text.Trim() + ",'" + textBox_Name.Text.Trim() + "',0)"; } else//edit { szTitle = "商品分类信息-修改"; szSql = "UPDATE base_prod SET PROD_NAME='" + textBox_Name.Text.Trim() + "',PROD_RMRK = '" + textBox_Desc.Text.Trim() + "' WHERE PROD_ID=" + textBox_Code.Text.Trim(); } string szErr = ""; try { int iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); if (iRst < 1) { MessageBox.Show("保存出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr); } else { szSql = "编号" + mszCode + "-分类名称" + mszName; MyFunc.WriteToDbLog(szTitle, szSql, "MSG", MyStart.giUserID); MessageBox.Show("保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); GridDataRefresh(); //dataGridView1.Refresh(); MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",OK"); } groupBoxInf.Enabled = false; groupBoxList.Enabled = true; textBox_Code.Text = mszCode; textBox_Name.Text = mszName; textBox_Desc.Text = mszInf; } catch (Exception ex) { MessageBox.Show("保存失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } MyStart.oMyDb.Close(); }
private void button_Qry_Click(object sender, EventArgs e) { MyFunc.WriteToDbLog("查询市场交易汇总", "", "MSG", MyStart.giUserID); string szBgn = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_Bgn.Value); string szEnd = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_End.Value); dataGridViewRst.Rows.Clear(); MyFunc.GridInit(ref dataGridViewRst, mszTitle, mszTitleWidth, 15, miDefRows, true); if (MyStart.gszMrktName.Length > 0) { mszRptTitle = MyStart.gszMrktName + "交易汇总表"; } else { mszRptTitle = "市场交易汇总表"; } string szDateCondition = "jy_tim>='" + szBgn + "' and jy_tim<='" + szEnd + "'"; string szSql = "select '" + MyStart.gszMrktName + "',count(*), format(sum(prod_w - prod_nw) / 1000, 3)," + "format(sum(prod_amount) / 100, 2),format(sum(prod_amount) * 10 / sum(prod_w - prod_nw), 2)," + "format(sum(MKT_BUYER_FEE) / 100, 2), format(sum(MKT_SELLER_FEE) / 100, 2)," + "format(sum(MKT_BUYER_FEE + MKT_SELLER_FEE) / 100, 2), " + "format(sum(YTB_BUYER_FEE) / 100, 2), format(sum(YTB_SELLER_FEE) / 100, 2)," + "format(sum(YTB_BUYER_FEE + YTB_SELLER_FEE) / 100, 2), " + "format(sum(prod_amount + MKT_BUYER_FEE + MKT_SELLER_FEE + YTB_BUYER_FEE + YTB_SELLER_FEE) / 100, 2) " + "from rec_trade where CANCEL_MARK='N' and PROD_ID>0 and " + szDateCondition; string szErr = ""; try { DataSet ds = new DataSet(); int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询市场交易记录", "SQL=" + szSql + ",Err=" + szErr); goto Eend; } DataTable dt = ds.Tables[0]; int iNum = dt.Rows.Count; if (iNum == 0) { goto Eend; } //mDt = dt; int iCurNum = (iNum < miDefRows ? miDefRows : iNum); int iBgnRow = 0; MyFunc.GridWriteDt(ref dataGridViewRst, ref dt, iBgnRow, miCols, ref iCurNum); iBgnRow += iNum; if (iBgnRow == 0) { MessageBox.Show("没有数据", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); goto Eend; } miRows = iBgnRow; mszRptDate = szBgn + " 至 " + szEnd; button_Rpt.Enabled = true; } catch (Exception ex) { MessageBox.Show("查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } Eend: MyStart.oMyDb.Close(); }
public static int GetSysParaFromIni(string sIniFileName) { string str = ""; short sI; sI = MyIniFile.GetIniKeyString(sIniFileName, "Sys", "Login", ref MyStart.gszSysLogin); if (sI < 0) { MyStart.gszSysLogin = "******"; } sI = MyIniFile.GetIniKeyString(sIniFileName, "Sys", "Code", ref MyStart.gszSysCode); if (sI < 0) { MyStart.gszSysCode = "37601008"; } sI = MyIniFile.GetIniKeyString(sIniFileName, "Sys", "Pwd", ref str); if (sI < 0) { MyStart.gszSysPwd = "1234567890"; } else { if (str.Length == 16 && MyTools.StringIsHex(str)) { MyStart.gszSysPwd = MyTools.HideString_To_OpenString(str, MyIniFile.mszIniKey); MyStart.gszSysPwd = MyStart.gszSysPwd.Trim(); } else { MyStart.gszSysPwd = "1234567890"; } } // DB sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "IP", ref MyStart.gszDbIp); if (sI < 0) { MyStart.gszDbIp = "rm-wz9767aj327o0ai0ro.mysql.rds.aliyuncs.com"; } //MyStart.gszDbIp = "183.58.24.209";//生产IP sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Port", ref MyStart.gszDbPort); if (sI < 0) { MyStart.gszDbPort = "3306"; } //MyStart.gszDbPort = "8878";//生产端口 sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Srv", ref MyStart.gszDbSrv); if (sI < 0) { MyStart.gszDbSrv = "zsmkt"; } sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Login", ref MyStart.gszDbLogin); if (sI < 0) { MyStart.gszDbLogin = "******"; } /*sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Pwd", ref str); * if (sI < 0) * { * MyStart.gszDbPwd = "Ztb_1324";// ThisSqlAly02&&"; * } * else * { * if (str.Length == 16 && MyTools.StringIsHex(str)) * { * MyStart.gszDbPwd = MyTools.HideString_To_OpenString(str, MyIniFile.mszIniKey); * MyStart.gszDbPwd = MyStart.gszDbPwd.Trim(); * } * else * MyStart.gszDbPwd = "Ztb_1324";//ThisSqlAly02&&"; * }*/ if (MyStart.gszDbIp == "139.159.212.93") { MyStart.gszDbPwd = "4077232"; } else { MyStart.gszDbPwd = "Ztb_1324"; } return(0); }
private void button_Save_Click(object sender, EventArgs e) { string sIniFileName = Application.StartupPath + "\\YTB.ini"; int sI = 0; string sErrorMessage = ""; string sTmp; /* * if (textBox_Pwd1.Text.Trim() != textBox_Pwd2.Text.Trim()) * { * sI = -1; * sErrorMessage = "两次输入的系统登录密码不相等,请更正"; * goto Eend; * } * if (textBox_Pwd1.Text.Length > 8) * { * sI = -1; * sErrorMessage = "系统登录密码长度不能超过8个字节,请更正"; * goto Eend; * } * //if (textBox_SrvUserPass.Text.Length > 8) * //{ * // sI = -1; * // sErrorMessage = "数据库密码长度不能超过8个字节,请更正"; * // goto Eend; * //} */ sI = -1; MyStart.gszDbIp = textBox_SrvIP.Text.Trim(); MyStart.gszDbPort = textBox_SrvPort.Text.Trim(); MyStart.gszDbLogin = textBox_SrvUserName.Text.Trim(); MyStart.gszDbPwd = textBox_SrvUserPass.Text; MyStart.gszDbSrv = textBox_SrvDataBase.Text.Trim(); MyStart.gszYTBIp = textBox_YTB_IP.Text; MyStart.gszYTBPort = textBox_YTB_PORT.Text; MyStart.gszRdrPort = comboBox_Rdr_Comm.Text.Substring(4); MyStart.gszRdr2Port = comboBox_Rdr2_Comm.Text.Substring(4); MyStart.gszRdrBaud = comboBox_Rdr_Baud.Text; MyStart.gszPsPort = comboBox_PS_Comm.Text.Substring(4); MyStart.gszPsBaud = comboBox_PS_Baud.Text; /*sI = MyIniFile.SetIniKeyValue(sIniFileName, "Sys", "Login", MyStart.szSysLogin); * if (sI < 0) * { * sErrorMessage = "保存 " + sIniFileName + "文件的 Sys.Login" + " 项时出错"; * goto Eend; * } * * sTmp = MyTools.OpenString_To_HideString((textBox_Pwd1.Text + " ").Substring(0, 8)); * sI = MyIniFile.SetIniKeyValue(sIniFileName, "Sys", "Pwd", sTmp); * if (sI < 0) * { * sErrorMessage = "保存 " + sIniFileName + "文件的 Sys.Pwd" + " 项时出错"; * goto Eend; * }*/ sI = MyIniFile.SetIniKeyValue(sIniFileName, "Db", "IP", MyStart.gszDbIp); if (sI < 0) { sErrorMessage = "保存 " + sIniFileName + "文件的 Db.IP" + " 项时出错"; goto Eend; } sI = MyIniFile.SetIniKeyValue(sIniFileName, "Db", "Port", MyStart.gszDbPort); if (sI < 0) { sErrorMessage = "保存 " + sIniFileName + "文件的 Db.Port" + " 项时出错"; goto Eend; } sI = MyIniFile.SetIniKeyValue(sIniFileName, "Db", "Srv", MyStart.gszDbSrv); if (sI < 0) { sErrorMessage = "保存 " + sIniFileName + "文件的 Db.Srv" + " 项时出错"; goto Eend; } sI = MyIniFile.SetIniKeyValue(sIniFileName, "Db", "Login", MyStart.gszDbLogin); if (sI < 0) { sErrorMessage = "保存 " + sIniFileName + "文件的 Db.Login" + " 项时出错"; goto Eend; } if (textBox_SrvUserPass.Text.Length <= 8) { sTmp = MyTools.OpenString_To_HideString((textBox_SrvUserPass.Text + " ").Substring(0, 8), MyIniFile.mszIniKey); } else { sTmp = MyTools.OpenString_To_HideString((textBox_SrvUserPass.Text.Substring(0, 8)), MyIniFile.mszIniKey); sTmp += MyTools.OpenString_To_HideString((textBox_SrvUserPass.Text.Substring(8) + " ").Substring(0, 8), MyIniFile.mszIniKey); } sI = MyIniFile.SetIniKeyValue(sIniFileName, "Db", "Pwd", sTmp); if (sI < 0) { sErrorMessage = "保存 " + sIniFileName + "文件的 Db.Pwd" + " 项时出错"; goto Eend; } string szErr = ""; sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "YTB_SRV", MyStart.gszYTBIp, ref szErr); if (sI < 0) { sErrorMessage = "保存益通宝平台.IP" + " 项时出错"; goto Eend; } sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "YTB_PORT", MyStart.gszYTBPort, ref szErr); if (sI < 0) { sErrorMessage = "保存益通宝平台.端口" + " 项时出错"; goto Eend; } sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "RDR_PORT", MyStart.gszRdrPort, ref szErr); if (sI < 0) { sErrorMessage = "保存读卡器.连接端口" + " 项时出错"; goto Eend; } sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "RDR2_PORT", MyStart.gszRdr2Port, ref szErr); if (sI < 0) { sErrorMessage = "保存后台用读卡器.连接端口" + " 项时出错"; goto Eend; } sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "RDR_BAUD", MyStart.gszRdrBaud, ref szErr); if (sI < 0) { sErrorMessage = "保存读卡器.连接波特率" + " 项时出错"; goto Eend; } sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "PS_PORT", MyStart.gszPsPort, ref szErr); if (sI < 0) { sErrorMessage = "保存磅秤.连接端口" + " 项时出错"; goto Eend; } sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "PS_BAUD", MyStart.gszPsBaud, ref szErr); if (sI < 0) { sErrorMessage = "保存磅秤.连接波特率" + " 项时出错"; goto Eend; } Eend: //string sUserTZM = MyTools.sGetMachineTZM(); //if (MyStart.sUserAuthCode == MyTools.sGetAuthCode(sUserTZM)) // MyStart.bAuthCodeIsOK = true; //else // MyStart.bAuthCodeIsOK = false; button_Edit.Enabled = true; button_Save.Enabled = false; button_Quit.Enabled = false; button_Exit.Enabled = true; groupBox_YTB.Enabled = false; groupBox_RDR.Enabled = false; groupBox_PS.Enabled = false; groupBox_Db.Enabled = false; if (sI < 0) { MessageBox.Show("操作错误:" + sErrorMessage + "。", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MyFunc.WriteToDbLog("修改系统参数", "", "MSG", MyStart.giUserID); //MessageBox.Show("Ini文件保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } button_Exit.Select(); MyStart.oMyDb.Close(); }
private void WriteDataToGrid2(string szFirmName, string szID, string szBgn, string szEnd, ref int iBgnRow) { /* string szSql = "select b.USER_NAME,if (oper_type = 'ADD','买方充值'," + "if (oper_type = 'TRADE','买方消费',if (oper_type = 'CASH','买方取现',if (oper_type='CHG','买方换卡','买方取消交易'))))," + "format(sum(chg_val)/100,2) from rec_user a,sys_users b " + "where a.Oper_ID = b.USER_ID and b.USER_NAME = '" + szFirmName + "' and " + szDateCondition + " group by oper_type " + "union " + "select b.USER_NAME,if (oper_type = 'ADD','卖方充值'," + "if (oper_type = 'TRADE','卖方消费',if (oper_type = 'CASH','卖方取现',if (oper_type='CHG','卖方换卡','卖方取消交易'))))," + "format(sum(chg_val)/100,2) from rec_firm a,sys_users b " + "where a.Oper_ID = b.USER_ID and b.USER_NAME = '" + szFirmName + "' and " + szDateCondition + " group by oper_type " + "union " + "select '小计','-','-' from dual";*/ /*select z.USER_ID, z.USER_NAME,i as 买方提现,k as 卖方充值,l as 卖方提现,k-i-l as 结合 * from * (sys_users z * left join * (select a.Oper_ID as h,sum(a.Chg_Val) as i from rec_firm a where a.Oper_Type='TRADE' group by a.Oper_ID) x * on z.USER_ID=x.h) * left join * (select b.Oper_ID as j,sum(b.Chg_Val) as k,sum(c.Chg_Val) as l from rec_user b,rec_user c * where b.Oper_ID=c.Oper_ID and b.Oper_Type='ADD' and c.Oper_Type='CASH' group by b.Oper_ID,c.Oper_ID) y * on z.USER_ID=y.j * where z.USER_STAT='USED' */ Int64[] iItem = new Int64[miCols - 1]; string szSql = "select Oper_ID,sum(Chg_Val) from rec_user where Oper_Type='ADD' and Oper_ID=" + szID + " and Oper_Time>='" + szBgn + "' and Oper_Time<='" + szEnd + "'"; string szErr = ""; DataSet ds = new DataSet(); int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询磅房交易记录", "SQL=" + szSql + ",Err=" + szErr); MyStart.oMyDb.Close(); return; } DataRow dr = ds.Tables[0].Rows[0]; try { iItem[0] = Convert.ToInt64(dr[1]);//买方充值 } catch { iItem[0] = 0; } iItem[1] = iItem[0];//收入结余 szSql = "select Oper_ID,sum(Chg_Val) from rec_user where Oper_Type='CASH' and Oper_ID=" + szID + " and Oper_Time>='" + szBgn + "' and Oper_Time<='" + szEnd + "'"; szErr = ""; iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询磅房交易记录", "SQL=" + szSql + ",Err=" + szErr); MyStart.oMyDb.Close(); return; } dr = ds.Tables[0].Rows[0]; try { iItem[2] = Convert.ToInt64(dr[1]);//买方提现 } catch { iItem[2] = 0; } szSql = "select Oper_ID,sum(Chg_Val) from rec_firm where Oper_Type='CASH' and Oper_ID=" + szID + " and Oper_Time>='" + szBgn + "' and Oper_Time<='" + szEnd + "'"; szErr = ""; iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询磅房交易记录", "SQL=" + szSql + ",Err=" + szErr); MyStart.oMyDb.Close(); return; } dr = ds.Tables[0].Rows[0]; try { iItem[3] = Convert.ToInt64(dr[1]);//卖方提现 } catch { iItem[3] = 0; } iItem[4] = iItem[2] + iItem[3]; //支出结余 iItem[5] = iItem[1] - iItem[4]; //总结余 szSql = szID + "-" + szFirmName; for (int index = 0; index < miCols - 1; index++) { szSql += "#" + ((decimal)iItem[index] / 100).ToString("0,000.00"); } MyFunc.GridWriteData(ref dataGridViewRst, szSql, ref iBgnRow); }
public bool HttpPost(string HttpCmd, string SendData, string szKey, ref Dictionary <string, string> objRecv) { bool bResult = false; try { HttpSendClass ThisSendData = new HttpSendClass(); ThisSendData.data = SendData; string ThisUrl = MyStart.gszHttpSrv;// SrvUrl;// + "/" + HttpCmd; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ThisUrl); request.Method = "POST"; //request.ContentType = "application/x-www-form-urlencoded"; request.ContentType = "application/json"; request.Accept = "*/*"; request.Timeout = 15000; request.AllowAutoRedirect = false; // Send Order string sOrder = SendData;// ObjToJson<HttpSendClass>(ThisSendData); //sOrder = "{\"kv\":1,\"dn\":\"90000001\",\"nc\":\"20171122220809031\",\"data\":\"XuZOwUeF9GP434d9wQP4FaIdL76il+okXYWTDGwvZxDiMISld4cWiZlNXua3W0z+q5FQ6MAC0Oke/o3fw6qY9Q==\",\"sign\":\"0d94466ce73af685f473bf722f8d9e11\"}"; //save to log -- add by lily 2018.09.20 MyIniFile.WriteLog("HTTP", "Send=" + sOrder); using (StreamWriter requestStream = new StreamWriter(request.GetRequestStream())) { requestStream.Write(sOrder); } // Receive ReturnBag string szRecv = ""; //HttpReceClass ReceClass = new HttpReceClass(); Dictionary <string, string> objItem; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.Default))// Encoding.GetEncoding("GBK")))//Encoding.UTF8)) { szRecv = reader.ReadToEnd(); //save to log -- add by lily 2018.09.20 MyIniFile.WriteLog("HTTP", "Recv=" + szRecv); } //ReceClass = "";// JsonToT<HttpReceClass>(sStr); JavaScriptSerializer js = new JavaScriptSerializer(); objItem = js.Deserialize <Dictionary <string, string> >(szRecv); } objRecv = objItem; // 是否失败 if (!objItem.ContainsKey("rc"))//无返回码 { sErrMsg = "返回的数据中无返回码rc"; goto Eend; } if (objItem["rc"].ToString() != "00") { sErrMsg = "rc=" + objItem["rc"] + "(" + objItem["rcDetail"] + ")"; goto Eend; } // check Sign string szSrcSign = objItem["sign"]; objItem.Remove("sign"); objItem.Add("key", szKey); string szDstSign = ""; bool bRst = GetReqSign(objItem, ref szDstSign); if (szSrcSign.CompareTo(szDstSign.ToLower()) != 0) { sErrMsg = "Receive data Sign Err.(cal sign=" + szDstSign + ")"; goto Eend; } //objItem.Remove("key"); objItem.Add("sign", szSrcSign); //check txnId ,key if (HttpCmd.CompareTo(objItem["txnId"]) != 0) { sErrMsg = "Receive data txnId Err."; goto Eend; } if (szKey.CompareTo(objItem["key"]) != 0) { sErrMsg = "Receive data key Err."; goto Eend; } sErrMsg = "HttpPost success."; bResult = true; } catch (Exception ex) { sErrMsg = "HttpPost Exception = " + ex.Message; //save to log -- add by lily 2018.09.20 MyIniFile.WriteLog("HTTP", "Oper err=" + ex.Message); } Eend: return(bResult); }
private void button_Save_Click(object sender, EventArgs e) { if (DialogResult.No == MessageBox.Show("请确认要保存该卖方信息", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { MessageBox.Show("取消当前保存操作", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string szSql; string szTitle; string szErr = ""; int iRst; string[] szItem = comboBox_Cert.Text.Split(','); try { if (IsNew)// textBox_Name.Enabled)//add { szTitle = "卖方基本信息-新增"; if (textBox_Cert.TextLength == 0) { MessageBox.Show("请输入卖方联系人身份证号", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_Cert.SelectAll(); textBox_Cert.Focus(); return; } if (textBox_Cell.TextLength == 0) { MessageBox.Show("请输入卖方联系电话", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_Cell.SelectAll(); textBox_Cell.Focus(); return; } szSql = "select * from base_store where STORE_NAME='" + textBox_Name.Text.Trim() + "'"; DataSet ds = new DataSet(); iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst < 0) { MessageBox.Show("查询信息出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr); goto Eend; } if (ds.Tables[0].Rows.Count == 1) { MessageBox.Show("卖方名称不能重复,请重新输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=卖方名称不能重复,请重新输入"); textBox_Name.SelectAll(); textBox_Name.Focus(); goto Eend; } szSql = "INSERT INTO base_store(STORE_NAME,STORE_ADDR,STORE_BOSS,STORE_TEL,CERT_TYPE,CERT_ID,CERT_VALID," + "STORE_PERSON,STORE_CELL,STORE_TYPE,CITY,RMRK,STORE_STAT) VALUES " + "('" + textBox_Name.Text.Trim() + "','" + textBox_Addr.Text.Trim() + "','" + textBox_Boss.Text.Trim() + "','" + textBox_Cell.Text.Trim() + "'," + Convert.ToInt16(szItem[0]) + ",'" + textBox_Cert.Text.Trim() + "','" + dateTimePicker_valid.Value + "','" + textBox_Person.Text.Trim() + "','" + textBox_Cell.Text.Trim() + "'," + comboBox_Type.SelectedIndex + 1 + ",'ZHONGSHAN','" + textBox_Desc.Text.Trim() + "','USED')"; } else//edit { szTitle = "卖方基本信息-修改"; szSql = "UPDATE base_store set STORE_ADDR = '" + textBox_Addr.Text.Trim() + "',STORE_NAME = '" + textBox_Name.Text.Trim() + "',STORE_BOSS = '" + textBox_Boss.Text.Trim() + "',STORE_TEL = '" + textBox_Cell.Text.Trim() + "',CERT_TYPE = " + Convert.ToInt16(szItem[0]) + ",CERT_ID = '" + textBox_Cert.Text.Trim() + "',CERT_VALID = '" + dateTimePicker_valid.Value + "',STORE_PERSON = '" + textBox_Person.Text.Trim() + "',STORE_CELL = '" + textBox_Cell.Text.Trim() + "',STORE_TYPE = " + (comboBox_Type.SelectedIndex + 1) + ",RMRK = '" + textBox_Desc.Text.Trim() + "' WHERE STORE_ID=" + textBox_Code.Text.Trim(); } iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); if (iRst < 1) { MessageBox.Show("保存出错(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",Err=" + szErr); } else { szSql = "编号" + textBox_Code.Text + "-卖方名" + textBox_Name.Text; MyFunc.WriteToDbLog(szTitle, szSql, "MSG", MyStart.giUserID); MessageBox.Show("保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); GridDataRefresh(); //dataGridView1.Refresh(); MyIniFile.WriteLog(szTitle, "SQL=" + szSql + ",OK"); } groupBoxInf.Enabled = false; groupBoxList.Enabled = true; textBox_Code.Text = mszCode; textBox_Name.Text = mszName; textBox_Addr.Text = mszAddr; textBox_Boss.Text = mszBoss; comboBox_Cert.Text = mszCertType; textBox_Cert.Text = mszCert; dateTimePicker_valid.Text = mszValid; textBox_Person.Text = mszPerson; textBox_Cell.Text = mszCell; comboBox_Type.Text = mszType; textBox_Desc.Text = mszInf; } catch (Exception ex) { MessageBox.Show("保存失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } Eend: MyStart.oMyDb.Close(); }
private void button_Login_Click(object sender, EventArgs e) { //String szYear = System.DateTime.Now.Year.ToString(); //int iMonth = System.DateTime.Now.Month; //if (System.DateTime.Now > DateTime.Parse("2018.12.31")) //{ // MessageBox.Show("读程序参数错误,请检查!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // return; //} DataSet ds = new DataSet(); string szErr = ""; string szSql = "select user_pwd,user_id,USER_APP,USER_NAME,USER_STAT from sys_users where user_login='******'";// and USER_STAT='STOP'"; int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); MyStart.oMyDb.Close(); if (iRst != 0) { MessageBox.Show("连接数据库失败(错误原因:" + szErr + ")", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("登录", "SQL=" + szSql + ",Err=" + szErr); return; } int iNum = ds.Tables[0].Rows.Count; if (iNum != 1) { MessageBox.Show("没有用户信息", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("登录", "SQL=" + szSql + ",Err=没有用户信息"); return; } DataRow dr = ds.Tables[0].Rows[0]; if (dr[4].ToString().ToUpper() == "STOP") { MessageBox.Show("该帐号已停用,请重新登录", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("登录", "SQL=" + szSql + ",Err=该帐号已停用,请重新登录"); textBox_Name.Focus(); return; } string szPwd = MyTools.HideString_To_OpenString(dr[0].ToString(), MyStart.gszPwdKey); if (textBox_PW.Text.Trim() == szPwd.Trim()) { MyStart.giUserID = Convert.ToInt16(dr[1]); MyStart.gszUserPwd = textBox_PW.Text.Trim(); MyStart.gszUserApp = dr[2].ToString(); MyStart.gszUsername = dr[3].ToString(); MyStart.UserCheckIn = true; string sIniFileName = Application.StartupPath + "\\YTB.ini"; int sI = 0; string sErrorMessage = ""; MyStart.gszSysLogin = textBox_Name.Text; sI = MyIniFile.SetIniKeyValue(sIniFileName, "Sys", "Login", MyStart.gszSysLogin); if (sI < 0) { sErrorMessage = "保存 " + sIniFileName + "文件的操作员信息" + " 项时出错"; MessageBox.Show("操作错误:" + sErrorMessage + "。", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Close(); } else { MessageBox.Show("登录信息错误,请重新输入", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_Name.Focus(); return; } }
/* * public static void GetIni(ref string szSysLogin, ref string szSysPwd, * ref string szDbIp, ref string szDbPort, ref string szDbSrv, * ref string szDbLogin, ref string szDbPwd) * { * string str = ""; * short sI; * string sIniFileName = Application.StartupPath + mszIniFile; * * sI = MyIniFile.GetIniKeyString(sIniFileName, "Sys", "Login", ref szSysLogin); * if (sI < 0) szSysLogin = "******"; * * sI = MyIniFile.GetIniKeyString(sIniFileName, "Sys", "Pwd", ref str); * if (sI < 0) * { * szSysPwd = "1234567890"; * } * else * { * if (str.Length == 16 && MyTools.StringIsHex(str)) * { * szSysPwd = MyTools.HideString_To_OpenString(str, mszIniKey); * szSysPwd = szSysPwd.Trim(); * } * else * szSysPwd = "1234567890"; * } * * // DB * sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "IP", ref szDbIp); * if (sI < 0) szDbIp = "rm-bp15ol05h0es8f5eco.mysql.rds.aliyuncs.com"; * sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Port", ref szDbPort); * if (sI < 0) szDbPort = "3306"; * sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Srv", ref szDbSrv); * if (sI < 0) szDbSrv = "zsmkt"; * sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Srv", ref szDbLogin); * if (sI < 0) szDbLogin = "******"; * sI = MyIniFile.GetIniKeyString(sIniFileName, "Db", "Pwd", ref str); * if (sI < 0) * { * szDbPwd = "Ztb_1324"; * } * else * { * if (str.Length == 16 && MyTools.StringIsHex(str)) * { * szDbPwd = MyTools.HideString_To_OpenString(str, mszIniKey); * szDbPwd = szDbPwd.Trim(); * } * else * szDbPwd = "Ztb_1324"; * } * }*/ public static bool SetIni(string SysLogin_New, string SysPwd_New, string KM_IP_New, string KM_PORT_New, string DB_Addr_New, int iSamRd_New, int iRFRd_New) { string str = ""; short sI; string sIniFileName = Application.StartupPath + "\\SYS.ini"; sI = MyIniFile.SetIniKeyValue(sIniFileName, "Sys", "Login", SysLogin_New); if (sI < 0) { str = "保存 " + sIniFileName + " 文件的 Sys.Login 项时出错"; goto Eend; } str = MyTools.OpenString_To_HideString((SysPwd_New + " ").Substring(0, 8), mszIniKey); sI = MyIniFile.SetIniKeyValue(sIniFileName, "Sys", "Pwd", str); if (sI < 0) { str = "保存 " + sIniFileName + "文件的 Sys.Pwd 项时出错"; goto Eend; } sI = MyIniFile.SetIniKeyValue(sIniFileName, "KM", "IP", KM_IP_New); if (sI < 0) { str = "保存 " + sIniFileName + " 文件的 KM.IP 项时出错"; goto Eend; } sI = MyIniFile.SetIniKeyValue(sIniFileName, "KM", "Port", KM_PORT_New); if (sI < 0) { str = "保存 " + sIniFileName + " 文件的 KM.Port 项时出错"; goto Eend; } sI = MyIniFile.SetIniKeyValue(sIniFileName, "DbSrv", "Addr", DB_Addr_New); if (sI < 0) { str = "保存 " + sIniFileName + " 文件的 DbSrv.Addr 项时出错"; goto Eend; } sI = MyIniFile.SetIniKeyValue(sIniFileName, "Comm", "SAM_DEV", iSamRd_New.ToString()); if (sI < 0) { str = "保存 " + sIniFileName + " 文件的 Comm.SAM_DEV 项时出错"; goto Eend; } sI = MyIniFile.SetIniKeyValue(sIniFileName, "Comm", "RF_DEV", iRFRd_New.ToString()); if (sI < 0) { str = "保存 " + sIniFileName + " 文件的 Comm.RF_DEV 项时出错"; goto Eend; } return(true); Eend: MessageBox.Show(str, "操作错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); }
private void button_Qry_Click(object sender, EventArgs e) { MyFunc.WriteToDbLog("查询买方交易汇总", "", "MSG", MyStart.giUserID); string szBgn = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_Bgn.Value); string szEnd = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_End.Value); dataGridViewRst.Rows.Clear(); MyFunc.GridInit(ref dataGridViewRst, mszTitle, mszTitleWidth, 15, miDefRows, true); if (MyStart.gszMrktName.Length > 0) { mszRptTitle = MyStart.gszMrktName + "买方交易汇总表"; } else { mszRptTitle = "买方交易汇总表"; } string szDateCondition = "jy_tim>='" + szBgn + "' and jy_tim<='" + szEnd + "'"; DataSet ds = new DataSet(); int iFirmNum = comboBox_Firm.Items.Count - 1; string[] szFirmID = new string[iFirmNum]; //user card id string[] szFirmName = new string[iFirmNum]; string[] szFirmCard = new string[iFirmNum]; //user card id int iBgnRow = 0; try { if (radioButton_Sel.Checked) { if (comboBox_Firm.SelectedIndex == 0)//all { //2)get STORE_CARD for (int i = 0; i < iFirmNum; i++) { string[] szItem = comboBox_Firm.Items[i + 1].ToString().Split('-'); szFirmID[i] = szItem[0]; szFirmName[i] = szItem[1]; szFirmCard[i] = szFirmID[i]; //3)get data if (szFirmCard[i].Trim().Length > 0) { WriteDataToGrid(szFirmName[i], szFirmCard[i], szDateCondition, ref iBgnRow); } } } else//only one firm { //2)get STORE_CARD string[] szItem = comboBox_Firm.Items[comboBox_Firm.SelectedIndex].ToString().Split('-'); szFirmID[0] = szItem[0]; szFirmName[0] = szItem[1]; szFirmCard[0] = szFirmID[0]; //3)get data if (szFirmCard[0].Trim().Length > 0) { WriteDataToGrid(szFirmName[0], szFirmCard[0], szDateCondition, ref iBgnRow); } } } if (radioButton_Input.Checked) { szFirmID[0] = textBox_Card.Text.Trim(); szFirmCard[0] = szFirmID[0]; //check card and get name string szSql = "select user_name from base_ucard where user_card='" + szFirmCard[0] + "'"; string szErr = ""; int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询买方卡失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询买方卡信息", "SQL=" + szSql + ",Err=" + szErr); goto Eend; } int iNum = ds.Tables[0].Rows.Count; if (iNum == 0) { MessageBox.Show("系统里无此买方卡,请换卡!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询买方卡信息", "SQL=" + szSql + ",Err=系统里无此买方卡"); goto Eend; } if (iNum > 1) { MessageBox.Show("重复发卡,请换卡!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询买方卡信息", "SQL=" + szSql + ",Err=重复发卡"); goto Eend; } DataRow dr = ds.Tables[0].Rows[0]; szFirmName[0] = dr[0].ToString(); //3)get data if (szFirmCard[0].Trim().Length > 0) { WriteDataToGrid(szFirmName[0], szFirmCard[0], szDateCondition, ref iBgnRow); } } if (radioButton_name.Checked) { szFirmID[0] = textBox_Card.Text.Trim(); szFirmCard[0] = szFirmID[0]; //check card and get name string szSql = "select user_card,user_name from base_ucard where user_name like '%" + textBox_name.Text + "%'"; string szErr = ""; int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询买方卡失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询买方卡信息", "SQL=" + szSql + ",Err=" + szErr); goto Eend; } iFirmNum = ds.Tables[0].Rows.Count; if (iFirmNum == 0) { MessageBox.Show("系统里无此买方卡,请换卡!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询买方卡信息", "SQL=" + szSql + ",Err=系统里无此买方卡"); goto Eend; } for (int i = 0; i < iFirmNum; i++) { DataRow dr = ds.Tables[0].Rows[i]; string[] szItem = comboBox_Firm.Items[i + 1].ToString().Split('-'); szFirmID[i] = dr[0].ToString(); szFirmName[i] = dr[1].ToString(); szFirmCard[i] = szFirmID[i]; //3)get data if (szFirmCard[i].Trim().Length > 0) { WriteDataToGrid(szFirmName[i], szFirmCard[i], szDateCondition, ref iBgnRow); } } } if (iBgnRow == 0) { MessageBox.Show("没有数据", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); goto Eend; } miRows = iBgnRow; mszRptDate = szBgn + " 至 " + szEnd; button_Rpt.Enabled = true; } catch (Exception ex) { MessageBox.Show("查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } Eend: MyStart.oMyDb.Close(); }
private void button_Qry_Click(object sender, EventArgs e) { MyFunc.WriteToDbLog("查询取款汇总", "", "MSG", MyStart.giUserID); string szBgn = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_Bgn.Value); string szEnd = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dateTimePicker_End.Value); string szTable = ""; if (MyStart.gszMrktName.Length > 0) { mszRptTitle = MyStart.gszMrktName + ""; } else { mszRptTitle = ""; } /* * if (radioButton_buyer.Checked) * { * szTable = "rec_user"; * mszRptTitle += "买方"; * } * if (radioButton_seller.Checked) * { * szTable = "rec_firm"; * mszRptTitle += "卖方"; * }*/ mszRptTitle += "取款汇总表"; string szDateCondition = "Oper_Time>='" + szBgn + "' and Oper_Time<='" + szEnd + "'"; /*string szSql = "select " + "case when b.USER_NAME is not null then b.USER_NAME else '合计' end as '收银员'," + "case when oper_subtype is not null then oper_subtype else '小计' end as '取款类型'," + "count(chg_val) as 取款笔数,format(sum(chg_val) / 100, 2) as 取款金额(元) from " + szTable + " a,sys_users b where oper_type = 'CASH' and a.Oper_ID=b.USER_ID "; + + if (comboBox_Type.SelectedIndex > 0)//only one type + { + szSql += " and oper_subtype='" + comboBox_Type.Text.Trim() + "' "; + } + if (comboBox_POS.SelectedIndex > 0)//only one oper + { + string[] szX = comboBox_POS.Text.Split('-'); + szSql += " and a.Oper_ID=" + szX[0]; + } + if (!(textBox_buyer.Text.Length == 0 && comboBox_Buyer.SelectedIndex == 0))//only one buyer + { + string[] szX = comboBox_Buyer.Text.Split('-'); + szSql += " and a.Card_No='" + szX[0] + "' "; + } + szSql += " and " + szDateCondition + " group by b.USER_NAME, oper_subtype with rollup";*/ string szSql = "select " + "case when Z.USER_NAME is not null then Z.USER_NAME else '合计' end as '收银员'," + "case when X_TYPE is not null then X_TYPE else '小计' end as '取款类型'," + "sum(A) as 卖方取款笔数,format(sum(B) / 100, 2) as '卖方取款金额(元)',sum(C) as 买方取款笔数,format(sum(D) / 100, 2) as '买方取款金额(元)'," + "sum(A + C) as 取款总笔数, format(sum(B + D) / 100, 2) as '取款总金额(元)' " + "from " + "(select X_ID, X_TYPE, A, B, C, D from " + " (select Oper_ID as X_ID, Oper_SubType as X_TYPE, count(Chg_Val) as A, sum(Chg_Val) as B from rec_firm where Oper_Type = 'CASH' and " + szDateCondition + " group by Oper_ID, Oper_SubType) X," + " (select Oper_ID as Y_ID, Oper_SubType as Y_TYPE, count(Chg_Val) as C, sum(Chg_Val) as D from rec_user where Oper_Type = 'CASH' and " + szDateCondition + " group by Oper_ID, Oper_SubType) Y " + " where X_ID = Y_ID and X_TYPE = Y_TYPE" + ") XX,sys_users Z where XX.X_ID = Z.USER_ID "; if (comboBox_POS.SelectedIndex > 0)//only one oper { string[] szX = comboBox_POS.Text.Split('-'); szSql += " and Z.USER_ID=" + szX[0]; } szSql += " group by Z.USER_NAME,XX.X_TYPE with rollup"; try { DataSet ds = new DataSet(); string szErr = ""; int iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { MessageBox.Show("查询失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); MyIniFile.WriteLog("查询取款汇总", "SQL=" + szSql + ",Err=" + szErr); goto Eend; } DataTable dt = ds.Tables[0]; if (dataGridViewRst.Columns.Count > 0) { dataGridViewRst.Columns.Clear(); } dataGridViewRst.DataSource = dt; dataGridViewRst.Refresh(); int iNum = dt.Rows.Count; if (iNum == 0) { button_Rpt.Enabled = false; MessageBox.Show("没有数据", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); goto Eend; } int iCurNum = (iNum < miDefRows ? miDefRows : iNum); int iBgnRow = 0; //MyFunc.GridWriteDt(ref dataGridViewRst, ref dt, iBgnRow, miCols, ref iCurNum); iBgnRow += iNum; if (iBgnRow == 0) { goto Eend; } miRows = iBgnRow; mszRptDate = szBgn + " 至 " + szEnd; button_Rpt.Enabled = true; } catch (Exception ex) { MessageBox.Show("查询失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } Eend: MyStart.oMyDb.Close(); }