private void btnOK_Click(object sender, EventArgs e) { string cashier_name = cmbUsername.Text.Trim(); string password = txtPassword.Text.Trim(); if(password == ""){ lblMsg.Text = "密码不能为空"; lblMsg.Visible = true; return; } CashierBLL cb = new CashierBLL(); string xml = cb.cashierLogin(cashier_name, password); try { string is_success = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/is_success").InnerText; if (is_success == "T") { CashierBLL cashierBll = new CashierBLL(); StaticData.Cashier.cashier_id = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/cashier_id").InnerText; StaticData.Cashier.cashier_no = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/cashier_no").InnerText; StaticData.Cashier.cashier_name = cmbUsername.Text; cashierBll.setConfig(StaticData.Cashier); lblMsg.Text = "登录成功"; lblMsg.Visible = true; this.DialogResult = DialogResult.OK; this.Close(); } else if (is_success == "F") { string error_msg = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/error_msg").InnerText; lblMsg.Text = error_msg; lblMsg.Visible = true; } else { string error_msg = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/error_msg").InnerText; lblMsg.Text = error_msg; lblMsg.Visible = true; } } catch (Exception ex) { lblMsg.Text = "异常:" + ex.Message; lblMsg.Visible = true; } }
private void BindCashier() { CashierBLL cb = new CashierBLL(); string xml = cb.getCashiers(); ArrayList cashiers = new ArrayList(); try { XmlNodeList nodelists = XMLStrHelper.GetXmlNodeListByXpath(xml, "Alipay/item"); int selIndex = 0; if (nodelists.Count > 0) { for (int i = 0; i < nodelists.Count; i++) { string cashier_name = nodelists.Item(i).InnerText; cashiers.Add(cashier_name); if (cashier_name == StaticData.Cashier.cashier_name) { selIndex = i; } } cmbUsername.DataSource = cashiers; cmbUsername.SelectedIndex = selIndex; } else { lblMsg.Text = "您还未添加收银员请到服务端添加"; lblMsg.Visible = true; } } catch (Exception ex) { lblMsg.Text = "异常:" + ex.Message; lblMsg.Visible = true; } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ConfigBLL configBll = new ConfigBLL(); CashierBLL cashierBll = new CashierBLL(); DeviceBLL deviceBll = new DeviceBLL(); string path = System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Yunfu"; //第一次启动 if (!Directory.Exists(path))//不存在path路径 { Directory.CreateDirectory(path); } if (!File.Exists(path + "\\Cashier.xml")) { StaticData.Cashier.cashier_id = "0"; cashierBll.setConfig(StaticData.Cashier); } if (!File.Exists(path + "\\Device.xml")) { deviceBll.setConfig(StaticData.Device); } if (!File.Exists(path + "\\Config.xml")) { StaticData.Config.isPrint = "0"; StaticData.Config.isVoice = "1"; StaticData.Config.dualPrint = "1"; StaticData.Config.userLptPrint = "0"; StaticData.Config.LptName = "LPT1"; StaticData.Config.printerName = new PrintDocument().PrinterSettings.PrinterName; configBll.setConfig(StaticData.Config); } StaticData.Device = deviceBll.getConfig(); StaticData.Config = configBll.getConfig(); StaticData.Cashier = cashierBll.getConfig(); AlipayBLL ab = new AlipayBLL(); string xml = ab.verify(); try { string is_success = XMLStrHelper.GetXmlNodeByXpath(xml,"Alipay/is_success").InnerText; if (is_success == "T") { FormLogin frmLogin = new FormLogin(); frmLogin.ShowDialog(); if (frmLogin.DialogResult == DialogResult.OK) { Application.Run(new FormMain()); } else { Application.Exit(); } } else { try { string error_msg = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/error_msg").InnerText; FormDevice frmDevice = new FormDevice(error_msg); frmDevice.ShowDialog(); } catch(Exception ex) { throw ex; } } } catch (Exception ex) { MessageHelper.ShowError("异常" + ex.Message); } }
private void btmPsd_Click(object sender, EventArgs e) { string cashier_name = cmbUsername.Text.Trim(); string password = txtPassword.Text.Trim(); string newpassword = txtPsd.Text.Trim(); string repassword = txtRePsd.Text.Trim(); if(password == ""){ lblPsdMsg.Text = "密码不能为空"; lblPsdMsg.Visible = true; return; } if (newpassword != repassword) { lblPsdMsg.Text = "两次密码不一致"; lblPsdMsg.Visible = true; return; } CashierBLL cb = new CashierBLL(); string xml = cb.cashierChangePsd(cashier_name, password, newpassword, repassword); try { string is_success = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/is_success").InnerText; if (is_success == "T") { panelPsd.Visible = false; lblMsg.Text = "密码修改成功"; lblMsg.Visible = true; txtPassword.Text = ""; } else if (is_success == "F") { string error_msg = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/error_msg").InnerText; lblPsdMsg.Text = error_msg; lblPsdMsg.Visible = true; } else { string error_msg = XMLStrHelper.GetXmlNodeByXpath(xml, "Alipay/error_msg").InnerText; lblPsdMsg.Text = error_msg; lblPsdMsg.Visible = true; } } catch (Exception ex) { lblMsg.Text = "异常:" + ex.Message; lblMsg.Visible = true; } }