private void button_SaveFee_Click(object sender, EventArgs e) { if (DialogResult.No == MessageBox.Show("确认要保存IC卡工本费吗?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return; } string szErr = ""; try { int iRst = MyFunc.SetSysParaToDb(MyStart.oMyDb, "FEE_CHG_CARD", miFee.ToString(), ref szErr); if (iRst < 0) { MessageBox.Show("操作错误:保存IC卡工本费时出错。", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MyFunc.WriteToDbLog("修改运营参数", "IC卡工本费" + textBox_Fee.Text + "元", "MSG", MyStart.giUserID); MessageBox.Show("保存成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("保存IC卡工本费失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } MyStart.oMyDb.Close(); }
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 button_Save_Click(object sender, EventArgs e) { string sIniFileName = Application.StartupPath + "\\SYS.ini"; int sI = -1; string sErrorMessage = ""; //string sTmp; MyStart.gszMrktMnger = textBox_mrkt_mnger.Text.Trim(); MyStart.gszMrktName = textBox_mrkt_name.Text.Trim(); MyStart.gszMrktAddr = textBox_mrkt_addr.Text.Trim(); MyStart.gszMrktTel = textBox_mrkt_tel.Text.Trim(); MyStart.gszFirmID = textBox_Firm_ID.Text.Trim(); //MyStart.gszPosID = textBox_Pos_ID.Text.Trim(); MyStart.gszCardFirmFirst = textBox_Card_Firm.Text.Trim(); MyStart.gszCardYtbFirst = textBox_Card_YTB.Text.Trim(); //MyStart.giFeeChgCard = Convert.ToInt16(Convert.ToDecimal(textBox_FeeChgCard.Text.Trim())*100)/100; if (textBox_FeeChgCard.Text.Trim().Length == 0) { MyStart.giFeeChgCard = 0; } else { MyStart.giFeeChgCard = (int)(Convert.ToDecimal(textBox_FeeChgCard.Text.Trim())); } string szWeight = ""; if (radioButton_kg.Checked) { MyStart.gszWeight = "公斤"; szWeight = "2"; } if (radioButton_jin.Checked) { MyStart.gszWeight = "斤"; szWeight = "1"; } dataGridViewTmn.ReadOnly = true; string szErr = ""; sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "MKT_GROUP", MyStart.gszMrktName, ref szErr); if (sI < 0) { sErrorMessage = "保存市场管理方" + " 项时出错"; goto Eend; } sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "MKT_NAME", MyStart.gszMrktName, ref szErr); if (sI < 0) { sErrorMessage = "保存市场名称" + " 项时出错"; goto Eend; } sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "MKT_ADDR", MyStart.gszMrktAddr, ref szErr); if (sI < 0) { sErrorMessage = "保存市场地址" + " 项时出错"; goto Eend; } sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "MKT_TELE", MyStart.gszMrktTel, ref szErr); if (sI < 0) { sErrorMessage = "保存市场电话" + " 项时出错"; goto Eend; } sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "FIRM_ID", MyStart.gszFirmID, ref szErr); if (sI < 0) { sErrorMessage = "保存供应商编码" + " 项时出错"; goto Eend; } //sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "POS_ID", MyStart.gszPosID, ref szErr); //if (sI < 0) //{ // sErrorMessage = "保存终端代码" + " 项时出错"; // goto Eend; //} sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "CARD_FIRM", MyStart.gszCardFirmFirst, ref szErr); if (sI < 0) { sErrorMessage = "保存卖方卡第一位编码" + " 项时出错"; goto Eend; } sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "CARD_YTB", MyStart.gszCardYtbFirst, ref szErr); if (sI < 0) { sErrorMessage = "保存买方卡第一位编码" + " 项时出错"; goto Eend; } sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "WEIGHT_UNIT", szWeight, ref szErr); if (sI < 0) { sErrorMessage = "保存计重单位" + " 项时出错"; goto Eend; } sI = MyFunc.SetSysParaToDb(MyStart.oMyDb, "FEE_CHG_CARD", MyStart.giFeeChgCard.ToString(), ref szErr); if (sI < 0) { sErrorMessage = "保存换卡手续费" + " 项时出错"; goto Eend; } int iRows = dataGridViewTmn.Rows.Count; int iNum = 0; string szSql = ""; DataSet ds = new DataSet(); int iRst = 0; try { szSql = "delete from base_value"; szErr = ""; iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); string szX = textBox_MinusType.Text.Replace("\r\n", ","); string[] szItem = szX.Split(','); iNum = szItem.Length; szSql = "insert into base_value (type,sub_type) values "; for (int i = 0; i < iNum; i++) { if (szItem[i].Trim().Length == 0) { continue; } szSql += "(2,'" + szItem[i] + "'),"; } szX = textBox_AddType.Text.Replace("\r\n", ","); szItem = szX.Split(','); iNum = szItem.Length; for (int i = 0; i < iNum; i++) { if (szItem[i].Trim().Length == 0) { continue; } szSql += "(1,'" + szItem[i] + "'),"; } szSql = szSql.Substring(0, szSql.Length - 1); szErr = ""; iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); for (int i = 0; i < iRows; i++) { string szPsamID = dataGridViewTmn.Rows[i].Cells[0].Value.ToString().Trim(); string szPosID = dataGridViewTmn.Rows[i].Cells[1].Value.ToString().Trim(); string szPosName = dataGridViewTmn.Rows[i].Cells[2].Value.ToString().Trim(); string szPsamStat = "N"; if (dataGridViewTmn.Rows[i].Cells[3].Value.ToString().Trim().CompareTo("有效") == 0) { szPsamStat = "Y"; } szSql = "select * from base_psam where psam_no='" + szPsamID + "'"; //string szErr=""; iRst = MyStart.oMyDb.ReadData(szSql, "tableA", ref ds, ref szErr); if (iRst != 0) { sErrorMessage = "保存终端编码(查询失败)" + " 项时出错"; goto Eend; } iNum = ds.Tables[0].Rows.Count; if (iNum == 0)//add { szSql = "INSERT INTO base_psam (TMN_CODE,TMN_NAME,PSAM_NO,PSAM_STAT) VALUES ('" + szPosID + "','" + szPosName + "','" + szPsamID + "','" + szPsamStat + "')"; } else//edit { szSql = "UPDATE base_psam SET TMN_CODE = '" + szPosID + "',TMN_NAME='" + szPosName + "'," + "PSAM_STAT = '" + szPsamStat + "' WHERE PSAM_NO='" + szPsamID + "'"; } iRst = MyStart.oMyDb.WriteData(szSql, ref szErr); } } catch (Exception ex) { ex.ToString(); } Eend: button_Edit.Enabled = true; button_Save.Enabled = false; button_Quit.Enabled = false; button_Exit.Enabled = true; groupBox_para.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(); }