/// <summary> /// 打印充值信息 /// </summary> /// <param name="branchNo">门店信息</param> /// <param name="cardId">会员卡号</param> /// <param name="accAmt">充值金额</param> /// <param name="sendAmt">赠送金额</param> /// <param name="remAmt">卡内余额</param> private void Print(string branchNo, string cardId, decimal accAmt, decimal sendAmt, decimal remAmt) { List <string> list = new List <string>(); list.Add("储值卡充值"); string text = "分店: " + branchNo; string item = "会员编号: " + cardId.ToString(); string item2 = "充值金额: " + accAmt.ToString(Gattr.PosSaleAmtPoint); string item3 = "赠送余额: " + sendAmt.ToString(Gattr.PosSaleAmtPoint); string item4 = "卡内余额: " + remAmt.ToString(Gattr.PosSaleAmtPoint); string item5 = "充值付款方式: " + SIString.TryStr(this.comboBox1.SelectedItem.ToString()); list.Add(text); list.Add(item); list.Add(item2); list.Add(item3); list.Add(item4); list.Add(item5); Gattr.PosPrinter.OpenPrinter(Gattr.PosModel, Gattr.PosPort); Gfunc.PrintHeader(); List <PrintString> print = new List <PrintString>(); foreach (String str in list) { print.Add(new PrintString(str)); } Gfunc.PrintOut(print); Gfunc.SendToAPIPrint(); }
/// <summary> /// 窗体首次加载事件逻辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmLogin_Load(object sender, EventArgs e) { Gfunc.InitPosSysSet(); Gattr.Bll.dbOpen(); this.label1.Text = "门店:" + Gattr.BranchName + " 版本号:" + Application.ProductVersion; }
/// <summary> /// 检查是否连接服务器 /// </summary> /// <returns>成功联网否则断网</returns> public bool TestConnect() { bool isConnect = false; bool isok = true; string errorMessage = string.Empty; Dictionary <string, object> _dic = null; string result = string.Empty; try { _dic = Gfunc.GetServiceParameter(); result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Testconn", _dic, ref isok, ref errorMessage); if (!string.IsNullOrEmpty(result)) { if (result != "-10" || result != "-20") { if (result == "1") { isConnect = true; } } } } catch (Exception ex) { LoggerHelper.Log("MsmkLogger", "LL.POS->PosServericeBll-->TestConn:" + ex.ToString(), LogEnum.ExceptionLog); } return(isConnect); }
private void Print(string flowNo, bool isSr, string payName, decimal amount, string memo) { List <PrintString> list = new List <PrintString>(); string text = amount.ToString(Gattr.PosSaleAmtPoint); string str = "分店:" + Gattr.BranchNo; string str2 = "收银员:" + Gattr.OperId; string item = DateTime.Now.ToString("yyyy.MM.dd HH:mm") + "\r\n"; string text2; if (isSr) { text2 = "非交易收入[" + payName + "]:"; } else { text2 = "非交易支出[" + payName + "]:"; } text2 += text.PadLeft(Gattr.PrtLen - Encoding.Default.GetByteCount(text2) - Encoding.Default.GetByteCount(text), ' '); list.Add(new PrintString(str + " " + str2)); list.Add(new PrintString(flowNo)); list.Add(new PrintString(item)); list.Add(new PrintString(text2)); list.Add(new PrintString(string.IsNullOrEmpty(memo) ? "" : ("备注:" + memo + "\n"))); //list.Add(str + " " + str2); //list.Add(flowNo); //list.Add(item); //list2.Add(text2); //list2.Add(string.IsNullOrEmpty(memo) ? "" : ("备注:" + memo + "\n")); Gattr.PosPrinter.OpenPrinter(Gattr.PosModel, Gattr.PosPort); Gfunc.PrintHeader(); Gfunc.PrintOut(list); Gfunc.SendToAPIPrint(); }
private void button2_Click(object sender, EventArgs e) { if (Gfunc.InitSystem() == 1) { this.tbText.Text = Gattr.BranchNo + " = 分支\r\n" + Gattr.PosId + " = PosId\r\n" + Gattr.WebPosServicePath + " = serviceFileName \r\n" + Gattr.HttpAddress; } }
private void btnPrint_Click(object sender, EventArgs e) { try { if (this.chkCashBox.Checked) { Gfunc.OpenCash(); // string strMemo = Language.GetString("#0514"); // Gattr.Bll.WriteRetailLog("OPD", 0M, strMemo, Gattr.CashierNo, "", 0M, true); // Gattr.Bll.WriteSysLog(Gattr.LogFile, strMemo, strMemo, 1); } //Gattr.PosPrinter.OpenPrinter(Gattr.PrinterName, Gattr.PrinterPort); //Gattr.PosPrinter.PrintOut("\r\n"); string strOut = ""; List <t_pos_printer_out> listOut = new List <t_pos_printer_out>(); for (int i = 0; i < this.listBox.Items.Count; i++) { if (Gattr.PosPrinter.IsWindowPrinter) { t_pos_printer_out item = new t_pos_printer_out { BigFont = false, Text = this.listBox.Items[i].ToString() }; listOut.Add(item); } else { strOut = strOut + this.listBox.Items[i].ToString() + "\n"; } } if (Gattr.PosPrinter.IsWindowPrinter) { Gattr.PosPrinter.PrintOut(listOut); } else { //Gattr.PosPrinter.PrintOut(strOut); //Gattr.PosPrinter.FooterEmptyLine(); //Gattr.PosPrinter.PrintCut(); } //Gattr.PosPrinter.ClosePrinter(); LoggerHelper.Log("MsmkLogger", System.DateTime.Now.ToString() + "【" + Gattr.OperId + "】进行打印对账信息!", LogEnum.SysLog); } catch (Exception exception) { MessageBox.Show(exception.Message, Gattr.AppTitle); } }
void GetBranchInfo() { try { Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); string errorMessage = string.Empty; bool isok = true; string json = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Getbrninfo", _dic, ref isok, ref errorMessage); if (isok) { if (!string.IsNullOrEmpty(json)) { if (json != "-10" && json != "-20") { DataTable table = JsonUtility.Instance.JsonToDataTable(json); if (table != null && table.Rows.Count > 0) { cbbBranch.Items.Clear(); foreach (DataRow dr in table.Rows) { string property = ExtendUtility.Instance.ParseToString(dr["property"]); if (property == "0") { ListItem item = new ListItem(SIString.TryStr(dr["branch_no"]), "[" + SIString.TryStr(dr["branch_no"]) + "]" + SIString.TryStr(dr["branch_name"])); cbbBranch.Items.Add(item); } } cbbBranch.SelectedIndex = 0; ListItem item1 = cbbBranch.SelectedItem as ListItem; String selectedItem = SIString.TryStr(item1.Key); GetPosStatus(selectedItem); MessageBox.Show("连接成功", Gattr.AppTitle); btnOk.Enabled = true; } } } } else { MessageBox.Show(errorMessage, Gattr.AppTitle); } } catch (Exception ex) { MessageBox.Show("连接失败", Gattr.AppTitle); LoggerHelper.Log("MsmkLogger", ex.ToString(), LogEnum.ExceptionLog); } }
private void btnOk_Click(object sender, EventArgs e) { try { if (this.tbNewPwd.Text.Trim() != this.tbReNewPwd.Text.Trim()) { MessageBox.Show("两次密码不一致!!!", Gattr.AppTitle); } _oper = Gattr.Bll.GetOperatorInfo(Gattr.OperId, SecurityUtility.Instance.GetMD5Hash(this.tbOldPwd.Text.Trim()), Gattr.BranchNo); if (_oper != null) { if (Gattr.Bll.UpdateOperPwd(_oper.oper_id, SecurityUtility.Instance.GetMD5Hash(this.tbNewPwd.Text.Trim())) > 0) { Gattr.Oper_Pwd = SecurityUtility.Instance.GetMD5Hash(this.tbNewPwd.Text.Trim()); Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("operId", Gattr.OperId); _dic.Add("pwd", Gattr.Oper_Pwd); bool isok1 = true; string errorMessage = string.Empty; string result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/UpdateOperPwd", _dic, ref isok1, ref errorMessage); if (result == "1") { this._updateStatus = true; MessageBox.Show("修改密码成功!!!", Gattr.AppTitle); LoggerHelper.Log("MsmkLogger", System.DateTime.Now.ToString() + Gattr.OperId + "修改密码成功!", LogEnum.SysLog); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("密码修改失败!!!", Gattr.AppTitle); LoggerHelper.Log("MsmkLogger", System.DateTime.Now.ToString() + Gattr.OperId + "修改密码失败!", LogEnum.SysLog); } } } else { MessageBox.Show("原密码错误!!!", Gattr.AppTitle); } } catch (Exception ex) { LoggerHelper.Log("MsmkLogger", "FrmUpatePwd--->btnOk_Click-->Error:" + ex.ToString(), LogEnum.ExceptionLog); } }
void GetPosStatus(String branch_no) { try { Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("branch_no", branch_no); string errorMessage = string.Empty; bool isok = true; string json = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Getposstatus", _dic, ref isok, ref errorMessage); if (isok) { if (!string.IsNullOrEmpty(json)) { if (json != "-10" && json != "-20") { DataTable table = JsonUtility.Instance.JsonToDataTable(json); if (table != null && table.Rows.Count > 0) { cbbPOS.Items.Clear(); if (table != null && table.Rows.Count > 0) { foreach (DataRow dr in table.Rows) { ListItem item = new ListItem(SIString.TryStr(dr["posid"]), "[" + SIString.TryStr(dr["posid"]) + "]" + SIString.TryStr(dr["posid"])); cbbPOS.Items.Add(item); } cbbPOS.SelectedIndex = 0; } } } } } else { MessageBox.Show(errorMessage, Gattr.AppTitle); } } catch (Exception ex) { LoggerHelper.Log("MsmkLogger", ex.ToString(), LogEnum.ExceptionLog); } }
private bool SaveNum() { if (string.IsNullOrEmpty(this.txtInput.Text.Trim())) { MessageBox.Show("数量不能为空!"); return(false); } if (!Gfunc.IsDigit(this.txtInput.Text.Trim())) { MessageBox.Show("数量含有非法数值!"); return(false); } if (Convert.ToDecimal(this.txtInput.Text.Trim()) == 0M) { MessageBox.Show("数量不能等于0!"); return(false); } this._num = Convert.ToDecimal(this.txtInput.Text.Trim()); return(true); }
private void btnOk_Click(object sender, EventArgs e) { if (!PosServericeBll.Instance.TestConnect()) { MessageBox.Show("断网状态,操作取消!", Gattr.AppTitle); } else { if (string.IsNullOrEmpty(this.txtAmount.Text.Trim())) { MessageBox.Show("金额不能为空!"); this.txtAmount.Focus(); } else { decimal amount = 0M; amount = Convert.ToDecimal(this.txtAmount.Text.Trim()) * Convert.ToDecimal((this.cbPayName.SelectedItem as ListItem).Value.Trim()); if (amount <= 0M) { MessageBox.Show("金额必须大于零!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.txtAmount.SelectAll(); this.txtAmount.Focus(); } else if (amount > 999999999M) { MessageBox.Show("金额值过大!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.txtAmount.SelectAll(); this.txtAmount.Focus(); } else { if (this.rbPayOut.Checked) { amount = -amount; } try { string flowNo = Gfunc.GetFlowNo(); ListItem item = this.cbPayName.SelectedItem as ListItem; string pay_name = item.Key.Substring(item.Key.LastIndexOf("]") + 1); List <t_pos_payflow> _listPay = new List <t_pos_payflow>(); t_pos_payflow _pay = new t_pos_payflow(); _pay.flow_id = 1; _pay.flow_no = flowNo; _pay.branch_no = Gattr.BranchNo; _pay.sale_way = "A"; _pay.sale_amount = amount; _pay.pay_way = (this.cbPayName.SelectedItem as ListItem).Key.Substring(1, (this.cbPayName.SelectedItem as ListItem).Key.IndexOf("]") - 1); _pay.oper_date = DateTime.Now.ToString("s"); _pay.oper_id = Gattr.OperId; _pay.pos_id = Gattr.PosId; _pay.pay_amount = amount; _pay.coin_rate = 1M; _pay.convert_amt = amount; _pay.memo = this.txtMemo.Text.Trim(); _pay.coin_type = "RMB"; _pay.com_flag = "1"; _pay.pos_flag = "1"; _pay.pay_name = pay_name; _listPay.Add(_pay); Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); string pay = JsonUtility.Instance.ObjectToJson <t_pos_payflow>(_listPay); _dic.Add("pay", pay); bool isok = true; string errorMessage = string.Empty; if (PosServericeBll.Instance.TestConnect()) { string json = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Addflow", _dic, ref isok, ref errorMessage); if (isok) { if (!string.IsNullOrEmpty(json)) { string message = string.Empty; switch (json) { case "-10": message = "参数错误"; break; case "-20": message = "权限不足"; break; case "1": //TODO :保存数据本地 _pay.com_flag = "1"; if (Gattr.Bll.SaveNonTrading(_pay)) { Gfunc.SetFlowNo(); message = "付款成功"; bool isok1 = true; if (this.rbPayOut.Checked) { isok1 = false; } this.Print(_pay.flow_no, isok1, _pay.pay_name, _pay.pay_amount.Value, _pay.memo); DialogResult = System.Windows.Forms.DialogResult.OK; //MessageBox.Show(message, Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); LoggerHelper.Log("MsmkLogger", System.DateTime.Now.ToString() + "【" + Gattr.OperId + "】进行非交易记录!" + _pay.sale_amount + "元", LogEnum.SysLog); } break; default: message = "付款失败"; break; } if (json != "1") { MessageBox.Show("付款失败!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("付款失败!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show(errorMessage, Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { if (Gattr.Bll.SaveNonTrading(_pay)) { Gfunc.SetFlowNo(); string message = "付款成功"; bool isok1 = true; if (this.rbPayOut.Checked) { isok1 = false; } this.Print(_pay.flow_no, isok1, _pay.pay_name, _pay.pay_amount.Value, _pay.memo); DialogResult = System.Windows.Forms.DialogResult.OK; MessageBox.Show(message, Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("付款失败!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } catch { MessageBox.Show("付款失败!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } } }
private void FrmDmSheetDetail_Load(object sender, EventArgs e) { this.Text = Gattr.AppTitle; this.SetItemView(); if (string.IsNullOrEmpty(this.SheetNO)) { MessageBox.Show("单号传递失败", Gattr.AppTitle); } else { this.dgvItemList.AutoGenerateColumns = false; this.dt = new DataTable("SheetDetail"); try { bool isok = true; string errorMessage = string.Empty; Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("sheet_no", SheetNO); string result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Getmodetail", _dic, ref isok, ref errorMessage); if (isok) { if (result != "-10" && result != "-20" && result != "-2" && result != "-1") { dtOld = JsonUtility.Instance.JsonToDataTable(result); dt = JsonUtility.Instance.JsonToDataTable(result); this.dgvItemList.DataSource = this.dt; } else { if (result == "-10") { //参数错误 MessageBox.Show("参数错误", Gattr.AppTitle); } else if (result == "-20") { //禁止操作 MessageBox.Show("禁止操作", Gattr.AppTitle); } else if (result == "-2") { //操作异常 MessageBox.Show("操作异常", Gattr.AppTitle); } else { //数据库连接失败 MessageBox.Show("数据库连接失败", Gattr.AppTitle); } } //this.dgvItemList.DataSource = this.dt; } else { MessageBox.Show(errorMessage, Gattr.AppTitle); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } //this.dateValid.Enabled = false; } }
/// <summary> /// 会员查询 /// </summary> public void SearchMember() { String mem_no = this.tbCardNo.Text.Trim(); if (mem_no.Length == 0) { MessageBox.Show("请输入会员编号", Gattr.AppTitle); this.tbCardNo.Focus(); } else { t_member_info meminfo = MemberService.Instance.GetMemberInfoByMemNo(mem_no); if (meminfo.code == "-1") { MessageBox.Show(meminfo.info, Gattr.AppTitle); this.tbCardNo.Focus(); } else { if (meminfo.code == "1") { t_member_info _temp = MemberService.Instance.CheckMemberinfoForLL(meminfo.mem_no); if (_temp != null) { if (_temp.code == "1") { if (_temp.time.Date == System.DateTime.Now.Date) { //接口参数 Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("vip_no", mem_no); _dic.Add("item_no", "80310891"); _dic.Add("plan_no", "WX80310891"); bool isok1 = true; string errorMessage = string.Empty; //参数提交 string result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/GetIsFirstSale", _dic, ref isok1, ref errorMessage); if (isok1) { if (result == "0") { meminfo.mem_type = "WX"; if (SetMemberEvent != null) { SetMemberEvent(meminfo); } DialogResult = DialogResult.OK; } else { MessageBox.Show("您领取过本活动的赠品!", Gattr.AppTitle); } } else { MessageBox.Show("接口信息获取错误!", Gattr.AppTitle); } } else { MessageBox.Show("您不是今日绑定的会员信息!本次活动仅限于当日绑定的会员!"); } } else { MessageBox.Show("您未将会员卡与微信绑定,无法参加活动,请使用微信绑定会员卡!", Gattr.AppTitle); } } } else { if (meminfo.code == "404") { meminfo.code = "1"; meminfo.mem_no = mem_no; } } } //if (meminfo.code == "1") //{ // if (SetMemberEvent != null) // { // SetMemberEvent(meminfo); // } // DialogResult = DialogResult.OK; //} //else //{ // MessageBox.Show(meminfo.info, Gattr.AppTitle); // this.txtInput.Focus(); //} } }
/// <summary> /// 添加购买商品事件 /// </summary> /// <param name="item_no"></param> private void addSaleItem(string item_no) { //初始化选择商品列表 PosBll pb = new PosBll(); //DataTable dtItemDetails = pb.GetItemDetails(item_no);//查询全部指定数据 DataTable dtItemDetails = null;//pb.GetItemDetails(item_no);//查询全部指定数据 //初始化选择商品列表 DataColumn dc = null; if (!_bColumnsHeader) { dc = dtSaleFlow.Columns.Add("NO", Type.GetType("System.Int32")); dc.AutoIncrement = true; //自动增加 dc.AutoIncrementSeed = 1; //起始为1 dc.AutoIncrementStep = 1; //步长为1 dc.AllowDBNull = false; // dc = dtSaleFlow.Columns.Add("Product", Type.GetType("System.String")); dc = dtSaleFlow.Columns.Add("Count", Type.GetType("System.String")); dc = dtSaleFlow.Columns.Add("FixedPrice", Type.GetType("System.Decimal")); dc = dtSaleFlow.Columns.Add("UnitPrice", Type.GetType("System.Decimal")); dc = dtSaleFlow.Columns.Add("Calculate", Type.GetType("System.Decimal")); this._bColumnsHeader = true; } DataRow newRow; newRow = dtSaleFlow.NewRow(); newRow["Product"] = dtItemDetails.Rows[0]["item_no"] + " \r\n" + dtItemDetails.Rows[0]["item_subname"]; newRow["Count"] = 1; newRow["FixedPrice"] = Gfunc.strToDecimal(dtItemDetails.Rows[0]["sale_price"].ToString()); newRow["UnitPrice"] = Gfunc.strToDecimal(dtItemDetails.Rows[0]["sale_price1"].ToString()); newRow["Calculate"] = Gfunc.strToDecimal(dtItemDetails.Rows[0]["sale_price1"].ToString()); #region //bool ifAdd = true; //if (this.dtSaleFlow.Rows.Count > 0) //{ // for (int i = 0; i < this.dtSaleFlow.Rows.Count; i++) // { // string strProduct = this.dtSaleFlow.Rows[i]["Product"].ToString(); // string strId = strProduct.Substring(0, strProduct.IndexOf("\r\n")); // //同一商品只需修改价格和数量。 // if (item_no.Equals(strId.Trim())) // { // decimal count = System.Decimal.Parse(this.dtSaleFlow.Rows[i]["Count"].ToString()) + 1; // decimal calculate = count * System.Decimal.Parse(dtItemDetails.Rows[0]["sale_price"].ToString()); // dtSaleFlow.Rows[i]["Product"] = dtItemDetails.Rows[0]["item_no"] + " \r\n" + dtItemDetails.Rows[0]["item_subname"]; // dtSaleFlow.Rows[i]["Count"] = count; // dtSaleFlow.Rows[i]["FixedPrice"] = UtilityClass.strToDecimal(dtItemDetails.Rows[0]["sale_price"].ToString()).ToString(); // dtSaleFlow.Rows[i]["UnitPrice"] = UtilityClass.strToDecimal(dtItemDetails.Rows[0]["sale_price1"].ToString()).ToString(); // dtSaleFlow.Rows[i]["Calculate"] = UtilityClass.strToDecimal(calculate.ToString()); // ifAdd = false; // } // //int sum = UtilityClass.strToDecimal(dtSaleFlow.Rows[i]["Calculate"]); // //this.lbTotal.Text = UtilityClass.strToDecimal(dtItemDetails.Rows[i]["Calculate"].ToString()).ToString(); // } // this.dgvSaleFlow.Refresh(); //} //if (ifAdd) //{ //合计 //} #endregion dtSaleFlow.Rows.Add(newRow); //合计总数 decimal decTotal = 0; decimal decCount = 0; for (int i = 0; i < dtSaleFlow.Rows.Count; i++) { decTotal = Gfunc.strToDecimal(dtSaleFlow.Rows[i]["Calculate"].ToString()) + decTotal; decCount = Gfunc.strToDecimal(dtSaleFlow.Rows[i]["Count"].ToString()) + decCount; } this.lbTotal.Text = decTotal.ToString(); this.lbCount.Text = decCount.ToString(); this.bindingSaleFlow.DataSource = dtSaleFlow; for (int i = 1; i <= dgvSaleFlow.RowCount; i++) { dgvSaleFlow.Rows[i - 1].Cells[0].Value = i.ToString(); } this.dgvSaleFlow.DataSource = bindingSaleFlow; //设置宽度 dgvSaleFlow.Columns["NO"].Width = 50; dgvSaleFlow.Columns["NO"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvSaleFlow.Columns["Product"].Width = 110; dgvSaleFlow.Columns["Product"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dgvSaleFlow.Columns["Count"].Width = 60; dgvSaleFlow.Columns["Count"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvSaleFlow.Columns["FixedPrice"].Width = 60; dgvSaleFlow.Columns["FixedPrice"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvSaleFlow.Columns["UnitPrice"].Width = 60; dgvSaleFlow.Columns["UnitPrice"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dgvSaleFlow.Columns["Calculate"].Width = 60; dgvSaleFlow.Columns["Calculate"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; }
private void FrmDmSheetDetail_Load(object sender, EventArgs e) { this.Text = Gattr.AppTitle; this.SetItemView(); if (string.IsNullOrEmpty(this.SheetNO)) { this.txtBranchNO.Text = "[" + Gattr.BranchNo + "]" + Gattr.BranchNo; this.txtSqPersion.Text = "[" + Gattr.OperId + "]" + Gattr.OperFullName; this.dateValid.Value = DateTime.Now.AddMonths(1); this.cmbType.Enabled = true; if (this.txtdBranchNO.Text.Trim() != "") { this.cmbType.SelectedIndex = 0; this.dateValid.Visible = this.cmbType.SelectedIndex == 0; this.lblValide.Visible = this.cmbType.SelectedIndex == 0; } if (!string.IsNullOrEmpty(this.ItemNo)) { this.AddItem(this.ItemNo); } if (currentStock != null) { this.BindItem(this.currentStock); } } else { if (this.IsApprove) { this.btnSave.Enabled = false; } this.dgvItemList.AutoGenerateColumns = false; if (this.SheetNO.Contains("YH")) { this.dt = new DataTable("SheetDetail"); try { bool isok = true; string errorMessage = string.Empty; Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("sheet_no", SheetNO); _dic.Add("trans_no", "YH"); string result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Getsdetail", _dic, ref isok, ref errorMessage); if (isok) { if (result != "-10" && result != "-20") { dt = JsonUtility.Instance.JsonToDataTable(result); this.dgvItemList.DataSource = this.dt; } else { if (result == "-10") { //参数错误 MessageBox.Show("参数错误", Gattr.AppTitle); } else { //禁止操作 MessageBox.Show("禁止操作", Gattr.AppTitle); } } //this.dgvItemList.DataSource = this.dt; } else { MessageBox.Show(errorMessage, Gattr.AppTitle); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } this.cmbType.Enabled = false; this.txtdBranchNO.ReadOnly = true; this.dateValid.Enabled = false; this.btnSelectBranch.Enabled = false; if (this.IsApprove) { this.btnSelectItem.Enabled = false; this.dgvItemList.ReadOnly = false; this.txtRemark.ReadOnly = false; this.btnApprove.Enabled = false; this.lblApprove.Visible = true; this.btnDel.Enabled = false; this.btnDelAll.Enabled = false; } } }
private void btnSearch_Click(object sender, EventArgs e) { string transNO = "YH"; if (this.cmbType.SelectedIndex == 0) { transNO = "YH"; } DateTime startDate = DateTime.Parse(this.dateStart.Value.ToShortDateString() + " 00:00"); DateTime endDate = DateTime.Parse(this.dateEnd.Value.ToShortDateString() + " 23:59"); if (endDate < startDate) { MessageBox.Show("结束时间要比开始时间大", Gattr.AppTitle); } else { int status = -1; if (this.cmbStatus.SelectedIndex == 1) { status = 0; } else if (this.cmbStatus.SelectedIndex == 2) { status = 1; } else { status = -1; } BaseInfoService.Instance.TransNO = transNO; BaseInfoService.Instance.BranchNO = Gattr.BranchNo; BaseInfoService.Instance.SheetNO = this.txtSheetNO.Text.Trim(); BaseInfoService.Instance.Status = status.ToString(); BaseInfoService.Instance.StartDate = startDate; BaseInfoService.Instance.EndDate = endDate; bool isok = true; try { if (isok) { dgvSheet.AutoGenerateColumns = false; if (dgvSheet.DataSource != null) { DataTable dt = (DataTable)dgvSheet.DataSource; dt.Rows.Clear(); dgvSheet.DataSource = dt; } //string mark = "GetPMSheetMaster"; //DataTable table = (DataTable)BaseInfoService.Instance.InvokeService(Gattr.HttpAddress, Gattr.WebPosServicePath, mark, ref isok, ""); //DataTable table = PosUploadServiceProvider.Instance.SearchMaster(Gattr.CONNECT_STRING, ref isok, Gattr.BranchNo, transNO, startDate.ToString(), endDate.ToString(), this.txtSheetNO.Text.Trim(), status.ToString()); //t_pm_sheet_master _master = new t_pm_sheet_master(); Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("branch_no", Gattr.BranchNo); _dic.Add("trans_no", transNO); _dic.Add("start", startDate.ToString()); _dic.Add("end", endDate.ToString()); _dic.Add("sheet_no", txtSheetNO.Text.Trim()); _dic.Add("approve_flag", status.ToString()); bool isok1 = true; string errorMessage = string.Empty; string result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Getsheet", _dic, ref isok1, ref errorMessage); if (isok1) { if (result != "-10" && result != "-20") { DataTable table = JsonUtility.Instance.JsonToDataTable(result); if (table != null && table.Rows.Count > 0) { this.dgvSheet.DataSource = table; } else { MessageBox.Show("没有找到数据", Gattr.AppTitle); } } else { if (result == "-10") { //参数错误 MessageBox.Show("参数错误", Gattr.AppTitle); } else { //禁止操作 MessageBox.Show("禁止操作", Gattr.AppTitle); } } } else { MessageBox.Show(errorMessage, Gattr.AppTitle); } //if (SIString.IsNullOrEmptyDataTable(table)) //{ // MessageBox.Show("没有找到数据", Gattr.AppTitle); //} //else //{ // this.dgvSheet.DataSource = table; //} } } catch (Exception exc) { throw exc; } } }
private void DisplayDt() { try { System.Collections.Generic.Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("branch_no", this.txtBranchNO.Text.Trim()); _dic.Add("item_clsno", this.textBox1.Text.Trim()); _dic.Add("item_brand", this.textBox2.Text.Trim()); _dic.Add("item_supcust", this.textBox3.Text.Trim()); _dic.Add("item_no", txtKey.Text.Trim()); String result = CommonProvider.InvokePOSAPI("Getstock", _dic); if (result != "404") { if (result != "-10" && result != "-20") { DataTable table = JsonUtility.Instance.JsonToDataTable(result); if (table != null) { this.dgItem.DataSource = table; this.dgItem.EditMode = DataGridViewEditMode.EditOnEnter; this.dgItem.Columns["item_no"].HeaderCell.Value = "货号"; this.dgItem.Columns["item_no"].MinimumWidth = 130; this.dgItem.Columns["item_no"].Width = 130; this.dgItem.Columns["item_name"].HeaderCell.Value = "商品名称"; this.dgItem.Columns["item_name"].MinimumWidth = 200; this.dgItem.Columns["item_name"].Width = 200; this.dgItem.Columns["item_size"].HeaderCell.Value = "规格"; this.dgItem.Columns["item_size"].MinimumWidth = 80; this.dgItem.Columns["item_size"].Width = 80; this.dgItem.Columns["branch_no"].HeaderCell.Value = "仓库"; this.dgItem.Columns["branch_no"].MinimumWidth = 100; this.dgItem.Columns["branch_no"].Width = 100; this.dgItem.Columns["stock_qty"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; this.dgItem.Columns["stock_qty"].DefaultCellStyle.Format = Gattr.PosSaleNumPoint; this.dgItem.Columns["stock_qty"].HeaderCell.Value = "实时库存"; this.dgItem.Columns["stock_qty"].MinimumWidth = 90; this.dgItem.Columns["stock_qty"].Width = 90; this.dgItem.Columns["item_clsname"].HeaderCell.Value = "类别"; this.dgItem.Columns["item_clsname"].MinimumWidth = 80; this.dgItem.Columns["item_clsname"].Width = 80; this.dgItem.Columns["code_name"].HeaderCell.Value = "品牌"; this.dgItem.Columns["code_name"].MinimumWidth = 70; this.dgItem.Columns["code_name"].Width = 70; this.dgItem.Columns["unit_no"].HeaderCell.Value = "单位"; this.dgItem.Columns["unit_no"].MinimumWidth = 70; this.dgItem.Columns["unit_no"].Width = 70; this.dgItem.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; this.dgItem.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; this.dgItem.ReadOnly = true; foreach (DataGridViewColumn column in this.dgItem.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } } } else { if (result == "-10") { MessageBox.Show("参数错误", Gattr.AppTitle); } else// if (result == "-20") { MessageBox.Show("权限不足", Gattr.AppTitle); } } } else { MessageBox.Show("服务器返回异常", Gattr.AppTitle); } } catch (Exception ex) { LoggerHelper.Log("MsmkLogger", "LL.POS->FrmStockQuery->DisplayDt-->Exception:" + ex.ToString(), LogEnum.ExceptionLog); } }
/// <summary> /// 初始化信息 /// </summary> void InitData() { if (base.IsHandleCreated) { base.Invoke(new EventHandler(delegate { btnOk.Enabled = false; buttonEx2.Enabled = false; })); } if (btnOk.IsHandleCreated) { btnOk.Invoke(new EventHandler(delegate { btnOk.Enabled = false; })); } if (buttonEx2.IsHandleCreated) { buttonEx2.Invoke(new EventHandler(delegate { buttonEx2.Enabled = false; })); } //else //{ // base.Invoke(new EventHandler(delegate // { // btnOk.Enabled = false; // buttonEx2.Enabled = false; // })); //} bool isAll = true; //1、初始化的基本信息2、各基本信息所占总初始化信息的百分比 //需要初始化的信息:商品分类10、商品条码20、商品40、支付方式10、基础信息类型,基础信息数据10、营业员10 try { int progressValue = this.progressBar1.Value; List <ThreadStruct> _list = new List <ThreadStruct>(); _list.Add(new ThreadStruct() { Desc = "数据库基本", Method = "InitDB", Percent = 5 }); _list.Add(new ThreadStruct() { Desc = "门店信息", Method = "Getbrninfo", Percent = 5 }); _list.Add(new ThreadStruct() { Desc = "商品分类", Method = "Getitemcls", Percent = 5 }); _list.Add(new ThreadStruct() { Desc = "商品条形码", Method = "Getbarcode", Percent = 5 }); _list.Add(new ThreadStruct() { Desc = "商品", Method = "Getiteminfo", Percent = 10 }); _list.Add(new ThreadStruct() { Desc = "商品价格", Method = "Getbraprc", Percent = 10 }); _list.Add(new ThreadStruct() { Desc = "商品库存", Method = "Getbrastock", Percent = 10 }); _list.Add(new ThreadStruct() { Desc = "基础信息类型", Method = "Getbasecode", Percent = 5 }); _list.Add(new ThreadStruct() { Desc = "基础信息数据", Method = "Getbase", Percent = 5 }); _list.Add(new ThreadStruct() { Desc = "营业员", Method = "Getoper", Percent = 5 }); _list.Add(new ThreadStruct() { Desc = "支付方式", Method = "Getpayinfo", Percent = 5 }); _list.Add(new ThreadStruct() { Desc = "快捷键", Method = "Getkey", Percent = 5 }); _list.Add(new ThreadStruct() { Desc = "促销规则", Method = "Getprule", Percent = 5 }); _list.Add(new ThreadStruct() { Desc = "促销", Method = "Getpmaster", Percent = 5 }); _list.Add(new ThreadStruct() { Desc = "促销详细", Method = "Getpdetail", Percent = 5 }); _list.Add(new ThreadStruct() { Desc = "组合商品", Method = "Getcomb", Percent = 5 }); _list.Add(new ThreadStruct() { Desc = "供应商", Method = "Getsup", Percent = 5 }); //_list.Add(new ThreadStruct() { Desc = "POS机设置", Method = "GetPosSet", Percent = 5 }); foreach (ThreadStruct ts in _list) { Thread.Sleep(500); if (ts.Method == "InitDB") { if (!Gfunc.InitDB()) { isAll = false; MessageBox.Show("更新" + ts.Desc + "时错误", Gattr.AppTitle); this.Invoke(new EventHandler(delegate { buttonEx2.Enabled = true; })); break; } } else { if (InvokeServices(ts.Method, true)) { progressValue = progressBar1.Value + ts.Percent; this.Invoke((MethodInvoker)(() => SetControlText("正在更新" + ts.Desc + "信息操作,已完成" + (progressValue) + "%", progressValue))); } else { isAll = false; MessageBox.Show("更新" + ts.Desc + "时错误", Gattr.AppTitle); this.Invoke(new EventHandler(delegate { buttonEx2.Enabled = true; })); break; } } } } catch (Exception ex) { LoggerHelper.Log("MsmkLogger", ex.ToString(), LogEnum.ExceptionLog); } finally { //Gattr.Bll.dbClose(); } if (isAll) { DialogResult = System.Windows.Forms.DialogResult.OK; } }
private void SaveData(bool istj) { if (this.btnApprove.Enabled) { if (this.txtdBranchNO.Text.Trim().Length == 0) { MessageBox.Show("发货仓库无法获取", Gattr.AppTitle); return; } if (this.txtdBranchNO.Text.Trim() == Gattr.BranchNo)//发货门店和申请门店相同 { MessageBox.Show("发货仓库和申请门店不能相同", Gattr.AppTitle); return; } if (this.dgvItemList.Rows.Count <= 0) { MessageBox.Show("没有收货商品信息", Gattr.AppTitle); return; } DataTable detail = new DataTable(); string[] dcs = new string[] { "item_no", "item_name", "large_qty", "real_qty", "other1", "item_price", "purchase_spec" }; foreach (string str in dcs) { DataColumn dc = new DataColumn(str); if (str != "real_qty" && str != "large_qty" && str != "item_price") { dc.DataType = Type.GetType("System.String"); } else { dc.DataType = Type.GetType("System.Decimal"); } if (!detail.Columns.Contains(str)) { detail.Columns.Add(dc); } } List <t_pm_sheet_detail> _details = new List <t_pm_sheet_detail>(); bool isok111 = true; foreach (DataGridViewRow dgvr in this.dgvItemList.Rows) { t_pm_sheet_detail _detail = new t_pm_sheet_detail(); //if (!string.IsNullOrEmpty(SheetNO)) //{ // _detail.sheet_no = SheetNO; //} _detail.item_no = ExtendUtility.Instance.ParseToString(dgvr.Cells["item_no"].Value); //t_cur_saleflow sale = Gattr.Bll.GetItemInfo(_detail.item_no); _detail.real_qty = ExtendUtility.Instance.ParseToDecimal(dgvr.Cells["real_qty"].Value); _detail.large_qty = ExtendUtility.Instance.ParseToDecimal(dgvr.Cells["real_qty"].Value) / ExtendUtility.Instance.ParseToDecimal(dgvr.Cells["purchase_spec"].Value); //数量规范性检测 if (_detail.real_qty.HasValue) { if (ExtendUtility.Instance.ParseToDecimal(_detail.real_qty.Value) <= 0) { MessageBox.Show("货号[" + _detail.item_no + "]的商品数量必须大于0", Gattr.AppTitle); isok111 = false; break; } } else { MessageBox.Show("货号[" + _detail.item_no + "]的商品数量不能为空", Gattr.AppTitle); isok111 = false; break; } _detail.orgi_price = ExtendUtility.Instance.ParseToDecimal(dgvr.Cells["item_price"].Value); _detail.sub_amt = ExtendUtility.Instance.ParseToDecimal(dgvr.Cells["item_price"].Value) * ExtendUtility.Instance.ParseToDecimal(dgvr.Cells["real_qty"].Value); _detail.other1 = ExtendUtility.Instance.ParseToString(dgvr.Cells["memo"].Value); _details.Add(_detail); } if (isok111 == false) { return; } bool isok = true; //string sheet_no = ExtendUtility.Instance.ParseToString(this.SheetNO); t_pm_sheet_master _master = new t_pm_sheet_master(); //_master.trans_no = "+"; //_master.trans_no = "YH"; _master.d_branch_no = Gattr.BranchNo; _master.branch_no = txtdBranchNO.Text.Remove(txtdBranchNO.Text.IndexOf("[")).Trim(); _master.voucher_no = SheetNO; _master.oper_id = Gattr.OperId; _master.order_man = Gattr.OperId; _master.confirm_man = Gattr.OperId; _master.sheet_amt = 0; _master.oper_date = ExtendUtility.Instance.ParseToDateTime(DateTime.Now.ToString("s")); //if (istj) //{ // _master.order_status = "0";//等待提交 //} //else //{ // _master.order_status = "t"; //} List <t_pm_sheet_master> _masters = new List <t_pm_sheet_master>(); _masters.Add(_master); string master1 = JsonUtility.Instance.ObjectToJson <t_pm_sheet_master>(_masters); string detail1 = JsonUtility.Instance.ObjectToJson <t_pm_sheet_detail>(_details); Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("master", master1); _dic.Add("detail", detail1); string errorMessage = string.Empty; string result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Addmisheet", _dic, ref isok, ref errorMessage); if (isok) { if (result != "-10" && result != "-20") { if (result == "1") { MessageBox.Show("保存成功", Gattr.AppTitle); this.btnApprove.Enabled = false; this.dgvItemList.Enabled = false; this.lblApprove.Visible = true; } else { string error = ""; switch (result) { case "-1": error = "数据库连接失败"; break; case "-2": error = "操作异常"; break; case "-5": error = "查找单据失败"; break; case "0": error = "保存失败"; break; default: error = "未知错误,保存失败"; break; } MessageBox.Show(error, Gattr.AppTitle); } } else { if (result == "-10") { //参数错误 MessageBox.Show("参数错误", Gattr.AppTitle); } else { //禁止操作 MessageBox.Show("禁止操作", Gattr.AppTitle); } } } else { MessageBox.Show(errorMessage, Gattr.AppTitle); } } }
/// <summary> /// 加载所有信息 /// </summary> void Action() { //首先判断门店信息,如果没有则提示初始化门店信息 //然后根据门店信息和POS机信息,初始化POS机信息 System.Threading.Thread.Sleep(500); //bool isok = false; try { SetControlVisible(false); LoggerHelper.Log("MsmkLogger", "信息初始化开始Starting...", LogEnum.InitLog); long result = Gfunc.InitEnvironment(); switch (result) { case -2: LoggerHelper.Log("MsmkLogger", "基本配置信息初始化失败Error", LogEnum.InitLog); break; case -1: LoggerHelper.Log("MsmkLogger", "取消基本配置信息初始化Cancel", LogEnum.InitLog); break; case -3: System.IO.File.Delete(AppDomain.CurrentDomain.BaseDirectory + Gattr.ApplicationXml); //Application.Exit(); Application.Restart(); return; //FrmInitData frmData = new FrmInitData(); //frmData.ShowDialog(); //this.Close(); //break; } SetControlVisible(true); if (result < 0) { if (result == -1) { Application.Exit(); } else { MessageBox.Show("基本配置信息初始化失败", Gattr.AppTitle); } return; } else { LoggerHelper.Log("MsmkLogger", "基本配置信息加载完成", LogEnum.InitLog); } Thread.Sleep(500); SetControlVisible(false); LoggerHelper.Log("MsmkLogger", "基本数据信息初始化开始Start", LogEnum.InitLog); Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); string errorMessage = string.Empty; bool isok = true; //通过 ping 判断丢包率 decimal d = ExtendUtility.Instance.ParseToDecimal(RunCmd(Gattr.serverUrl)); string res = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Testconn", _dic, ref isok, ref errorMessage); if (isok && res == "1" && d < 10) { Gattr.NetStatus = "【联网】"; FrmSyncPosData frmData = new FrmSyncPosData(true); if (frmData.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //TODO:数据初始化完成 显示主登录窗体 goto TOLOGIN; } else { LoggerHelper.Log("MsmkLogger", "取消基本数据信息初始化Cancel", LogEnum.InitLog); Application.Exit(); } } else { MessageBox.Show("服务器连接失败,将以断网方式进行销售。"); Gattr.NetStatus = "【断网】"; goto TOLOGIN; } TOLOGIN: Gattr.BranchName = Gattr.Bll.GetBranchNameByNo(Gattr.BranchNo); Gattr.AppTitle = Gattr.BranchName == string.Empty ? ConfigurationManager.AppSettings["appName"] : Gattr.BranchName; Gattr.adUrl = (Gattr.adUrl == string.Empty) ? AppDomain.CurrentDomain.BaseDirectory + "AD.htm" : Gattr.adUrl; //TODO:数据初始化完成 显示主登录窗体 LoggerHelper.Log("MsmkLogger", "基本数据信息初始化完成Complete", LogEnum.InitLog); Process[] processesByName = Process.GetProcessesByName("LL.POS.Transfer"); Process[] array3 = processesByName; for (int i = 0; i < array3.Length; i++) { Process process = array3[i]; process.Kill(); process.WaitForExit(); process.Close(); process.Dispose(); } String path = AppDomain.CurrentDomain.BaseDirectory + "LL.POS.Transfer.exe"; //String dbpath = AppDomain.CurrentDomain.BaseDirectory + "sale.db"; String dbpath = "sale.db"; Process.Start(new ProcessStartInfo() { FileName = path, Arguments = dbpath + " " + "transfer.ini" + " " + Gattr.AppTitle + " " + Gattr.client_id + " " + Gattr.access_token + " " + Gattr.serverUrl + " " + Gattr.MemberServiceUri + " " + Gattr.ServiceWay + " " + Gattr.UseToken }); FrmLogin frmLogin = new FrmLogin(this); frmLogin.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); LoggerHelper.Log("MsmkLogger", ex.ToString(), LogEnum.ExceptionLog); } }
/// <summary> /// 验证当前选择的POS的信息 /// </summary> /// <param name="branch_no"></param> /// <param name="posid"></param> /// <returns></returns> private static bool ValidatePos(string branch_no, string posid) { bool isok = false; try { string mac = ComputerUtility.Instance.GetMacAddress(); string disk = ComputerUtility.Instance.GetDiskVolumeSerialNumber(); if (disk == LL.Common.GobalStaticString.UN_KNOWN_DISK) { MessageBox.Show("获取机器信息失败", Gattr.AppTitle); return(false); } string hostname = System.Environment.MachineName; Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); bool isok1 = true; string errorMessage = string.Empty; string result1 = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Testconn", _dic, ref isok1, ref errorMessage); if (isok1 == true && result1 == "1") { _dic.Add("hostname", hostname); _dic.Add("hostmac", mac); _dic.Add("hostdisk", disk); _dic.Add("branch_no", branch_no); _dic.Add("posid", posid); string result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Validpos", _dic, ref isok1, ref errorMessage); if (isok1) { if (result != "-10" && result != "-20") { switch (result) { case "0": isok = true; break; case "1": //MessageBox.Show("注册成功", Gattr.AppTitle); isok = true; break; case "2": MessageBox.Show("该机器已注册其他POS机", Gattr.AppTitle); break; case "3": MessageBox.Show("该POS机已被其他机器注册", Gattr.AppTitle); break; case "-2": case "-1": default: MessageBox.Show("注册/验证POS机失败", Gattr.AppTitle); break; } } } } else { isok = true; // MessageBox.Show("注册/验证POS机失败", Gattr.AppTitle); // LoggerHelper.Log("MsmkLogger", "LL.POS->Init->FrmInitData->ValidatePos->Exception:" + errorMessage, LogEnum.ExceptionLog); } } catch (Exception ex) { MessageBox.Show("注册/验证POS机失败", Gattr.AppTitle); LoggerHelper.Log("MsmkLogger", "LL.POS->Init->FrmInitData->ValidatePos->Exception:" + ex.ToString(), LogEnum.ExceptionLog); } return(isok); }
public static void SendToAPIPrint() { bool IsOpen = false; switch (Gattr.PortType) { case "并口": SendToLTP(); break; case "串口": System.IO.Ports.SerialPort sPort = new System.IO.Ports.SerialPort(); sPort.PortName = Gattr.PortName; sPort.BaudRate = 9600; sPort.DataBits = 8; sPort.StopBits = (StopBits)Enum.Parse(typeof(StopBits), "1"); sPort.Parity = (Parity)Enum.Parse(typeof(Parity), "1"); sPort.Handshake = (Handshake)Enum.Parse(typeof(Handshake), "1"); IsOpen = POSUtility.Instance.OpenComPort(ref sPort); sPort.Dispose(); break; case "USB": IsOpen = POSUtility.Instance.OpenUSBPort(Gattr.PortName); break; case "驱动": Gfunc.SendToPrint(); //IsOpen = POSUtility.Instance.OpenPrinter(Gattr.PortName); break; case "网口": IsOpen = POSUtility.Instance.OpenNetPort(Gattr.PortName); break; } if (IsOpen) { if (((_listWinPrtStr != null) && (_listWinPrtStr.Count != 0))) { try { //开钱箱 IntPtr res = POSUtility.POS_KickOutDrawer(0x00, 100, 100); if ((uint)res != POSUtility.Instance.POS_SUCCESS) { MessageBox.Show("开钱箱失败!指令调用返回值:" + res.ToString(), "系统提示"); LoggerHelper.Log("MsmkLogger", "开钱箱失败!指令调用返回值:" + res.ToString(), LogEnum.SysLog); } POSUtility.POS_StartDoc(); POSUtility.POS_SetMode(0x00); POSUtility.POS_SetRightSpacing(0); POSUtility.POS_SetLineSpacing(80); foreach (t_pos_printer_out _out in _listWinPrtStr) { POSUtility.POS_FeedLine(); POSUtility.POS_S_TextOut(_out.Text, 0, 1, 1, POSUtility.Instance.POS_FONT_TYPE_STANDARD, POSUtility.Instance.POS_FONT_STYLE_NORMAL); } POSUtility.POS_FeedLines(4); POSUtility.POS_Reset(); POSUtility.POS_EndDoc(); _listWinPrtStr.Clear(); } catch (Exception exception) { MessageBox.Show(exception.Message, "系统提示"); LoggerHelper.Log("MsmkLogger", "API打印报错:" + exception.Message, LogEnum.SysLog); } } //关闭端口 POSUtility.Instance.ClosePrinterPort(); } else { if (Gattr.PortType != "驱动" && Gattr.PortType != "并口") { MessageBox.Show(Gattr.PortType + "端口打印机无效!", Gattr.AppTitle); LoggerHelper.Log("MsmkLogger", Gattr.PortType + "端口打印机无效!", LogEnum.SysLog); } } }
private void btnDel_Click(object sender, EventArgs e) { //string cashierNo = Gattr.CashierNo; //string msg = ""; //if (Gfunc.PosCheckGrant(ref cashierNo, PosGrant.UpdateDmSheet, ref msg)) //{ if (this.dgvSheet.CurrentRow != null) { string sheetNO = SIString.TryStr(this.dgvSheet.Rows[this.dgvSheet.CurrentRow.Index].Cells["sheet_no"].Value.ToString().Trim()); string str4 = SIString.TryStr(this.dgvSheet.Rows[this.dgvSheet.CurrentRow.Index].Cells["approve_name"].Value.ToString().Trim()); string strStatus = SIString.TryStr(this.dgvSheet.Rows[this.dgvSheet.CurrentRow.Index].Cells["order_status"].Value.ToString().Trim()); if ((sheetNO != "") && (str4 != "已审核")) { DialogResult dialogResult = new DialogResult(); if (strStatus == "t") { dialogResult = MessageBox.Show("当前选中单据为[" + sheetNO + "],是否删除?", Gattr.AppTitle, MessageBoxButtons.YesNo); } else { dialogResult = MessageBox.Show("当前选中单据[" + sheetNO + "]已经提交审核,是否删除?", Gattr.AppTitle, MessageBoxButtons.YesNo); } if (dialogResult == DialogResult.Yes) { Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("sheet_no", sheetNO); bool isok = true; string errorMessage = string.Empty; string result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Delpsheet", _dic, ref isok, ref errorMessage); if (isok && result != "") { switch (result) { case "1": MessageBox.Show("删除成功!", Gattr.AppTitle); btnSearch_Click(sender, e); break; case "0": MessageBox.Show("删除失败,请重试!", Gattr.AppTitle); break; case "-1": MessageBox.Show("记录不存在!", Gattr.AppTitle); break; case "-2": MessageBox.Show("返回异常!", Gattr.AppTitle); break; case "-3": MessageBox.Show("业务错误!-3", Gattr.AppTitle); break; default: MessageBox.Show("未知错误!", Gattr.AppTitle); break; } } //string transNO = sheetNO.Contains("DY") ? "DY" : "AP"; //string transNO = "YH"; //if (RetailGlobal.ServerBll.DelSheet(transNO, sheetNO) > 0) //{ // MessageBox.Show("单据[" + sheetNO + "]删除成功!", Gattr.AppTitle); // this.btnSearch_Click(sender, e); //} //else //{ // MessageBox.Show("单据[" + sheetNO + "]删除失败,请检查是否为已审核单据!", Gattr.AppTitle); // this.btnSearch_Click(sender, e); //} LoggerHelper.Log("MsmkLogger", System.DateTime.Now.ToString() + "【" + Gattr.OperId + "】进行删除要货单!", LogEnum.SysLog); } } else { MessageBox.Show("单据[" + sheetNO + "]状态为已审核,不能删除!", Gattr.AppTitle); } } else { MessageBox.Show("请先选中一行再进行操作!", Gattr.AppTitle); } //} }
/// <summary> /// F1查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSelectBranch_Click(object sender, EventArgs e) { #region test1 string type = "0,2"; using (FrmBranchSelect select = new FrmBranchSelect(type.ToString())) { select.ShowDialog(); if (!string.IsNullOrEmpty(select.BranchNO)) { bool isok = true; string errorMessage = string.Empty;; this.txtdBranchNO.Text = select.BranchNO; Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("branch_no", Gattr.BranchNo); _dic.Add("d_branch_no", this.txtdBranchNO.Text); string result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Getcomstock", _dic, ref isok, ref errorMessage); if (isok) { if (result != "-10" && result != "-20") { if (result != "-1" && result != "0" && result != "-2") { DataTable table = JsonUtility.Instance.JsonToDataTable(result); this.dt.Clear(); foreach (DataRow dr in table.Rows) { DataRow dr1 = this.dt.NewRow(); dr1["item_no"] = ExtendUtility.Instance.ParseToString(dr["item_no"]); dr1["item_subno"] = ""; dr1["item_name"] = ExtendUtility.Instance.ParseToString(dr["item_name"]); //dr1["item_size"] = ExtendUtility.Instance.ParseToString(dr["item_size"]); dr1["unit_no"] = ExtendUtility.Instance.ParseToString(dr["unit_no"]); dr1["real_qty"] = 1; dr1["other1"] = ""; dr1["stock"] = ExtendUtility.Instance.ParseToString(dr["item_stock"]); dr1["stock_qty"] = ExtendUtility.Instance.ParseToString(dr["d_stock_qty"]); this.dt.Rows.Add(dr1); } } else { string error = ""; switch (result) { case "-1": error = "记录不存在"; break; case "-2": error = "保存异常"; break; default: error = "保存失败"; break; } MessageBox.Show(error, Gattr.AppTitle); } } else { if (result == "-10") { //参数错误 MessageBox.Show("参数错误", Gattr.AppTitle); } else { //禁止操作 MessageBox.Show("禁止操作", Gattr.AppTitle); } } } else { MessageBox.Show(errorMessage, Gattr.AppTitle); } } } if (this.txtdBranchNO.Text.Trim() != "") { //string tradeType = Gattr.Bll.GetTradeType(this.txtdBranchNO.Text.Trim()); //if (tradeType.Equals("0") || tradeType.Equals("2")) //{ // this.cmbType.SelectedIndex = 0; // this.dateValid.Visible = this.cmbType.SelectedIndex == 0; // this.lblValide.Visible = this.cmbType.SelectedIndex == 0; //} //else //{ this.cmbType.SelectedIndex = 0; this.dateValid.Visible = this.cmbType.SelectedIndex == 0; this.lblValide.Visible = this.cmbType.SelectedIndex == 0; //} } #endregion }
//打印机检测 private void button1_Click(object sender, EventArgs e) { bool IsOpen = false; switch (Port) { case "并口": SendMoneyBox(cboxBK.Text); break; case "串口": System.IO.Ports.SerialPort sPort = new System.IO.Ports.SerialPort(); sPort.PortName = cboxCK.Text; sPort.BaudRate = 9600; sPort.DataBits = 8; sPort.StopBits = (StopBits)Enum.Parse(typeof(StopBits), "1"); sPort.Parity = (Parity)Enum.Parse(typeof(Parity), "1"); sPort.Handshake = (Handshake)Enum.Parse(typeof(Handshake), "1"); IsOpen = POSUtility.Instance.OpenComPort(ref sPort); sPort.Dispose(); break; case "USB": IsOpen = POSUtility.Instance.OpenUSBPort(cboxUSB.Text); break; case "驱动": Gfunc.OpenCash(); break; case "网口": IsOpen = POSUtility.Instance.OpenNetPort(maskedtboxIP.Text); break; } if (IsOpen) { try { if (Port == "并口") { //开钱箱 bool res = POSUtility.Instance.PrintESC(3); if (!res) { MessageBox.Show("开钱箱失败!指令调用返回值:" + res.ToString(), "系统提示"); LoggerHelper.Log("MsmkLogger", "开钱箱失败!指令调用返回值:" + res.ToString(), LogEnum.SysLog); } else { LoggerHelper.Log("MsmkLogger", Gattr.OperId + "通过打印设置打开钱箱", LogEnum.SysLog); } //关闭端口 POSUtility.Instance.ClosePrintLPT(); } else { IntPtr res = POSUtility.POS_KickOutDrawer(0x00, 100, 100); if ((uint)res != POSUtility.Instance.POS_SUCCESS) { MessageBox.Show("开钱箱失败!指令调用返回值:" + res.ToString(), "系统提示"); LoggerHelper.Log("MsmkLogger", "开钱箱失败!指令调用返回值:" + res.ToString(), LogEnum.SysLog); } else { LoggerHelper.Log("MsmkLogger", Gattr.OperId + "通过打印设置打开钱箱", LogEnum.SysLog); } //关闭端口 POSUtility.Instance.ClosePrinterPort(); } } catch (Exception exception) { MessageBox.Show(exception.Message, "系统提示"); } } else { if (Port != "驱动" && Port != "并口") { MessageBox.Show("端口打开失败,请检查一下端口选择是否正确!", Gattr.AppTitle); } } }
/// <summary> /// 提交反馈事件逻辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonEx1_Click(object sender, EventArgs e) { bool isok = true; String errorMessage = String.Empty; try { if (this.richTextBox1.Text.Trim().Length == 0) { MessageBox.Show("请输入反馈信息", Gattr.AppTitle); } else if (this.richTextBox1.Text.Trim().Length > 50) { MessageBox.Show("反馈信息不能超过50个字", Gattr.AppTitle); } else { Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("branch_no", Gattr.BranchNo); _dic.Add("posid", Gattr.PosId); _dic.Add("oper_id", Gattr.OperId); _dic.Add("content", this.richTextBox1.Text.Trim()); String _result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Testconn", _dic, ref isok, ref errorMessage); if (isok) { isok = false; switch (_result) { case "-10": errorMessage = "参数不正确"; break; case "-20": errorMessage = "权限不足"; break; case "1": isok = true; String _content = this.richTextBox1.Text.Trim(); _result = string.Empty; _result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Addfeedback", _dic, ref isok, ref errorMessage); if (isok) { isok = false; switch (_result) { case "-10": errorMessage = "参数不正确"; break; case "-20": errorMessage = "权限不足"; break; case "1": isok = true; errorMessage = "反馈提交成功"; break; default: errorMessage = "反馈提交失败"; break; } } break; default: if (errorMessage.Length == 0) { errorMessage = "数据返回错误"; } break; } MessageBox.Show(errorMessage, Gattr.AppTitle); if (isok) { DialogResult = System.Windows.Forms.DialogResult.OK; } } else { LoggerHelper.Log("MsmkLogger", "LL.POS->FrmFeedBack-->Exception:" + errorMessage, LogEnum.ExceptionLog); } } } catch (Exception ex) { LoggerHelper.Log("MsmkLogger", "LL.POS->FrmFeedBack-->Exception:" + ex.ToString(), LogEnum.ExceptionLog); } }
/// <summary> /// 调用服务更新数据库 /// </summary> /// <param name="mark"></param> /// <param name="isAll"></param> /// <returns></returns> bool InvokeServices(String mark, bool isAll) { bool result = false; //1、调用方法获取数据 //2、将数据导入到表 //bool isok = true; DataTable table = null; object obj; try { t_handle _t_handle = Gattr.Bll.SelectHandleData(); //obj = PosServiceProvider.Instance.InvokeService(Gattr.HttpAddress, Gattr.WebPosServicePath, mark, ref isok, Gattr.BranchNo); //obj = PosDownServiceProvider.Instance.InvokeService(Gattr.CONNECT_STRING, mark, ref isok, Gattr.BranchNo, "", 0, ""); Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("branch_no", Gattr.BranchNo); switch (mark) { case "Getiteminfo": string last_time = WindowsAPIUtility.GetLocalSysParam("download", "t_product_food", Gattr.LAST_UPDATE_TIME, Gattr.INI_FILE_PATH); _dic.Add("rid", _t_handle.t_product_food); _dic.Add("last_time", ExtendUtility.Instance.ParseToDateTime(last_time).ToString()); break; case "Getbrastock": string last_time1 = WindowsAPIUtility.GetLocalSysParam("download", "t_pos_branch_stock", Gattr.LAST_UPDATE_TIME, Gattr.INI_FILE_PATH); _dic.Add("rid", _t_handle.t_product_food_kc); _dic.Add("last_time", ExtendUtility.Instance.ParseToDateTime(last_time1).ToString()); break; case "Getbraprc": string last_time2 = WindowsAPIUtility.GetLocalSysParam("download", "t_pos_branch_price", Gattr.LAST_UPDATE_TIME, Gattr.INI_FILE_PATH); _dic.Add("rid", _t_handle.t_product_food_jg); _dic.Add("last_time", ExtendUtility.Instance.ParseToDateTime(last_time2).ToString()); break; case "Getbarcode": string last_time3 = WindowsAPIUtility.GetLocalSysParam("download", "barcode", Gattr.LAST_UPDATE_TIME, Gattr.INI_FILE_PATH); _dic.Add("rid", _t_handle.t_product_food_barcode); _dic.Add("last_time", ExtendUtility.Instance.ParseToDateTime(last_time3).ToString()); break; case "Getitemcls": //_dic.Add("rid", _t_handle.t_product_food_type); _dic.Add("rid", -1); break; case "Getbasecode": _dic.Add("rid", _t_handle.t_base_code_type); break; case "Getbase": _dic.Add("rid", _t_handle.t_base_code); break; case "Getoper": _dic.Add("rid", _t_handle.t_operator); break; case "Getpmaster": _dic.Add("rid", _t_handle.t_rm_plan_master); break; case "Getcomb": _dic.Add("rid", _t_handle.t_bd_item_combsplit); break; case "Getpdetail": _dic.Add("rid", _t_handle.t_rm_plan_detail); break; } string errorMessage = string.Empty; bool isok1 = true; obj = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/" + mark, _dic, ref isok1, ref errorMessage); if (isok1) { //if (isok) //{ // //获取数据 // //插入数据 // if (mark != "GetPosSet") // { string result1 = ExtendUtility.Instance.ParseToString(obj); //if (!string.IsNullOrEmpty(result1)) { if (result1 != "-10" && result1 != "-20") { table = JsonUtility.Instance.JsonToDataTable(result1); if (!SIString.IsNullOrEmptyDataTable(table)) { decimal rid = 0M; switch (mark) { case "Getitemcls": result = Gattr.Bll.InsertItemClsData(table, _t_handle.t_product_food_type, ref rid); if (result) { _t_handle.t_product_food_type = rid; } break; case "Getbarcode": result = Gattr.Bll.InsertBarcodeData(table, _t_handle.t_product_food_barcode, ref rid); if (result) { _t_handle.t_product_food_barcode = rid; } break; case "Getiteminfo": result = Gattr.Bll.InsertItemData(table, _t_handle.t_product_food, ref rid); if (result) { _t_handle.t_product_food = rid; } break; case "Getoper": result = Gattr.Bll.InsertCashierData(table, _t_handle.t_operator, ref rid); if (result) { _t_handle.t_operator = rid; } break; case "Getbasecode": result = Gattr.Bll.InsertBaseTypeData(table, _t_handle.t_base_code_type, ref rid); if (result) { _t_handle.t_base_code_type = rid; } break; case "Getbase": result = Gattr.Bll.InsertBaseData(table, _t_handle.t_base_code, ref rid); if (result) { _t_handle.t_base_code = rid; } break; case "Getpayinfo": result = Gattr.Bll.InsertPaymentInfo(table); break; case "Getkey": result = Gattr.Bll.InsertFunction(table); break; case "Getbrninfo": result = Gattr.Bll.InsertBrancheList(table); break; case "Getbraprc": result = Gattr.Bll.UpdateItemPrice(table, ref rid); if (result) { _t_handle.t_product_food_jg = rid; } break; case "Getbrastock": result = Gattr.Bll.UpdateItemStock(table, ref rid); if (result) { _t_handle.t_product_food_kc = rid; } break; case "Getprule": result = Gattr.Bll.InsertPlanRule(table); break; case "Getpmaster": result = Gattr.Bll.InsertPlanMaster(table, _t_handle.t_rm_plan_master, ref rid); if (result) { _t_handle.t_rm_plan_master = rid; } break; case "Getpdetail": result = Gattr.Bll.InsertPlanDetail(table, _t_handle.t_rm_plan_detail, ref rid); if (result) { _t_handle.t_rm_plan_detail = rid; } break; case "Getcomb": result = Gattr.Bll.InsertItemComb(table, _t_handle.t_bd_item_combsplit, ref rid); if (result) { _t_handle.t_bd_item_combsplit = rid; } break; case "Getsup": result = Gattr.Bll.InsertSupinfo(table); break; default: break; } //如果数据更新成功则更新标识信息 if (result) { Gattr.Bll.UpdateHandleData(_t_handle); } } else { result = true; } } } // } // else // { // // List<t_sys_pos_set> sets = JsonUtility.Instance.JsonToObject<List<t_sys_pos_set>>(obj.ToString()); // // result = Gattr.Bll.InsertPosSysSet(sets); // } //} //else //{ // MessageBox.Show(SIString.TryStr(obj), Gattr.AppTitle); //} } else { MessageBox.Show(errorMessage, Gattr.AppTitle); } } catch (Exception ex) { LoggerHelper.Log("MsmkLogger", ex.ToString(), LogEnum.ExceptionLog); } return(result); }
/// <summary> /// 生成对帐单据 /// </summary> /// <param name="storeNo"></param> /// <param name="posId"></param> /// <param name="cashierId"></param> /// <param name="dtFrom"></param> /// <param name="dtTo"></param> /// <param name="intPrintLen"></param> /// <returns></returns> public List <string> AccountReportFromServer(string storeNo, string posId, string cashierId, DateTime dtFrom, DateTime dtTo, int intPrintLen) { List <string> list3; List <string> list = new List <string>(); try { string str = ""; string str2 = string.Empty; string str3 = string.Empty; int num = 0; int result = 0; int num3 = 0; int num4 = 0; decimal num5 = 0M; decimal num6 = 0M; decimal num7 = 0M; string branchNo = Gattr.BranchNo;//storeNo.Substring(0, 4); DataSet set = new DataSet(); set = base._dal.GetPayCash(branchNo, cashierId, dtFrom, dtTo); if (set != null) { DataTable table = set.Tables["t_rm_cashier_info"]; if (((table == null) || (table.Rows.Count == 0)) || (Convert.ToInt32(table.Rows[0][0]) == 0)) { list.Add(str.PadLeft((intPrintLen < 0) ? 0 : intPrintLen, '-')); list.Add(Gfunc.PrintStrAlign("收银对帐 ", intPrintLen, TextAlign.Center)); str = ""; list.Add(str.PadLeft((intPrintLen < 0) ? 0 : intPrintLen, '-')); list.Add("收银员(" + cashierId + ")今天无收付款记录. "); return(list); } List <t_operator> cashierInfo = base._dal.GetOperatorInfo(Gattr.OperId, Gattr.BranchNo); list.Add(""); list.Add(Gfunc.PrintStrAlign(" 收银对帐单 ", intPrintLen, TextAlign.Center)); list.Add(Gfunc.PrintStrAlign("================", intPrintLen, TextAlign.Center)); str = ""; list.Add(str.PadLeft((intPrintLen < 0) ? 0 : intPrintLen, '-')); list.Add(" 机构: " + base._dal.GetBranchName(branchNo)); //list.Add(" 仓库: " + base._dal.GetBranchName(storeNo)); list.Add(" 收银机号: " + posId); list.Add(" 收 银 员: [" + cashierId.Trim() + "] " + cashierInfo[0].oper_name.Trim()); list.Add(" 对账日期: " + DateTime.Today.ToString("yyyy-MM-dd")); list.Add(" 首笔: " + Convert.ToDateTime(table.Rows[0][1]).ToString("s")); list.Add(" 末笔: " + Convert.ToDateTime(table.Rows[0][2]).ToString("s")); list.Add(" 笔数: " + table.Rows[0][0].ToString()); str = ""; list.Add(str.PadLeft((intPrintLen < 0) ? 0 : intPrintLen, '-')); DataTable table2 = set.Tables["t_rm_scash_info"]; if ((table2 != null) && (table2.Rows.Count > 0)) { result = 0; num5 = 0M; int.TryParse(table2.Rows[0]["count"].ToString(), out result); decimal.TryParse(table2.Rows[0]["amount"].ToString(), out num5); list.Add("赠送"); list.Add("--笔数: " + Gfunc.PrintStrAlign(result.ToString(), 6, TextAlign.Left) + "--金额: " + num5.ToString(Gattr.PosSaleAmtPoint)); } DataTable table3 = set.Tables["t_rm_jycash_info"]; decimal num8 = 0M; if ((table3 != null) && (table3.Rows.Count > 0)) { List <t_dict_payment_info> paymentInfo = base._dal.GetPaymentInfo(" pay_flag = '0' or pay_flag = '1' or pay_flag='6' "); foreach (t_dict_payment_info _info in paymentInfo) { for (int i = 1; i <= 3; i++) { switch (i) { case 1: str2 = "A"; str3 = "销售"; num = 1; break; case 2: str2 = "B"; str3 = "退货"; num = -1; break; case 3: str2 = "D"; str3 = "找零"; num = -1; break; } DataRow[] rowArray = table3.Select(string.Format(" pay_way='{0}' and sale_way='{1}' ", _info.pay_way, str2)); if ((rowArray != null) && (rowArray.Length > 0)) { int num10; if ((rowArray.Length > 0) && _info.pay_way.ToUpper().Equals("SAV")) { num10 = 0; while (num10 <= (rowArray.Length - 1)) { result = Convert.ToInt32(rowArray[num10]["count"]); num5 = Convert.ToDecimal(rowArray[num10]["amount"]); if ((result > 0) || (num5 > 0M)) { if (rowArray[num10]["memo"].ToString() == "1") { list.Add(_info.pay_name + "-项目" + str3); } else { list.Add(_info.pay_name + "-" + str3); } list.Add("--笔数: " + Gfunc.PrintStrAlign(result.ToString(), 6, TextAlign.Left) + "--金额: " + num5.ToString(Gattr.PosSaleAmtPoint)); if (num == 1) { num6 += num5 * _info.rate; num3 += result; } else if (num == -1) { num7 += num5 * _info.rate; num4 += result; } } num10++; } } else { for (num10 = 0; num10 <= (rowArray.Length - 1); num10++) { result = Convert.ToInt32(rowArray[num10]["count"]); num5 = Convert.ToDecimal(rowArray[num10]["amount"]); if ((result > 0) || (num5 > 0M)) { if ((rowArray[num10]["memo"].ToString() == "2") || _info.pay_way.ToUpper().Equals("ORD")) { if (str2 == "B") { list.Add(string.Format("退订货订金(人民币)", new object[0])); } else { list.Add(_info.pay_name + "-储值卡充值"); } } else if (rowArray[num10]["memo"].ToString() == "3") { list.Add(_info.pay_name + "-储值卡项目充值"); } else { list.Add(_info.pay_name + "-" + str3); } list.Add("--笔数: " + Gfunc.PrintStrAlign(result.ToString(), 6, TextAlign.Left) + "--金额: " + num5.ToString(Gattr.PosSaleAmtPoint)); switch (num) { case 1: num6 += num5 * _info.rate; num3 += result; break; case -1: num7 += num5 * _info.rate; num4 += result; break; } if (_info.pay_way == "RMB") { num8 += num5 * num; } } } } } } } } if ((num3 > 0) || (num4 > 0)) { list.Add(""); list.Add("收支合计 笔数: " + ((num3 + num4)).ToString() + " "); if (num4 > 0) { list.Add(Gfunc.PrintStrAlign("--支出笔数: " + num4.ToString(), 0x10, TextAlign.Left) + "支出金额: " + num7.ToString(Gattr.PosSaleAmtPoint)); } if (num3 > 0) { list.Add(Gfunc.PrintStrAlign("--收入笔数: " + num3.ToString(), 0x10, TextAlign.Left) + "收入金额: " + num6.ToString(Gattr.PosSaleAmtPoint)); } list.Add("--合计金额: " + ((num6 - num7)).ToString(Gattr.PosSaleAmtPoint)); list.Add(""); list.Add("人民币现金额: " + num8.ToString(Gattr.PosSaleAmtPoint)); str = ""; list.Add(str.PadLeft((intPrintLen < 0) ? 0 : intPrintLen, '-')); } } list.Add(Gfunc.PrintStrAlign("==完==", intPrintLen, TextAlign.Center)); list3 = list; } catch (Exception exception) { throw exception; } return(list3); }
private void SaveData(bool istj) { string cashierNo = Gattr.OperId; if (this.cmbType.SelectedIndex == -1) { MessageBox.Show("请选择单据类型!", Gattr.AppTitle); return; } if (this.cmbType.SelectedIndex == 0 || this.cmbType.SelectedIndex == -1) { if (this.txtdBranchNO.Text.Trim().Length == 0) { MessageBox.Show("请输入发货门店", Gattr.AppTitle); return; } if (this.txtdBranchNO.Text.Trim() == Gattr.BranchNo)//发货门店和申请门店相同 { MessageBox.Show("发货门店和申请门店不能相同", Gattr.AppTitle); return; } if (this.dgvItemList.Rows.Count <= 0) { MessageBox.Show("没有要货商品信息", Gattr.AppTitle); return; } DataTable detail = new DataTable(); string[] dcs = new string[] { "sheet_no", "item_no", "real_qty", "other1" }; foreach (string str in dcs) { DataColumn dc = new DataColumn(str); if (str != "real_qty") { dc.DataType = Type.GetType("System.String"); } else { dc.DataType = Type.GetType("System.Decimal"); } if (!detail.Columns.Contains(str)) { detail.Columns.Add(dc); } } decimal _sumAmt = 0M; List <t_pm_sheet_detail> _details = new List <t_pm_sheet_detail>(); bool isok111 = true; foreach (DataGridViewRow dgvr in this.dgvItemList.Rows) { t_pm_sheet_detail _detail = new t_pm_sheet_detail(); if (!string.IsNullOrEmpty(SheetNO)) { _detail.sheet_no = SheetNO; } _detail.item_no = ExtendUtility.Instance.ParseToString(dgvr.Cells["item_no"].Value); t_cur_saleflow sale = Gattr.Bll.GetItemInfo(_detail.item_no); _detail.real_qty = ExtendUtility.Instance.ParseToDecimal(dgvr.Cells["real_qty"].Value); if (istj) { if (_detail.real_qty.HasValue) { if (ExtendUtility.Instance.ParseToDecimal(_detail.real_qty.Value) <= 0) { MessageBox.Show("货号[" + _detail.item_no + "]的商品数量必须大于0", Gattr.AppTitle); isok111 = false; break; } } else { MessageBox.Show("货号[" + _detail.item_no + "]的商品数量不能为空", Gattr.AppTitle); isok111 = false; break; } //if (this.dgvItemList.Rows[e.RowIndex].Cells["stock_qty"].Visible == true) //{ // decimal stock_qty = ExtendUtility.Instance.ParseToDecimal( // this.dgvItemList.Rows[e.RowIndex].Cells["stock_qty"].Value); // if (result > stock_qty) // { // MessageBox.Show("要货数量不能大于发货门店库存", Gattr.AppTitle); // isok111 = false; // this.dgvItemList.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = this.EditBackValue; // } //} } _detail.other1 = ExtendUtility.Instance.ParseToString(dgvr.Cells["other1"].Value); _details.Add(_detail); } if (isok111 == false) { return; } bool isok = true; string sheet_no = ExtendUtility.Instance.ParseToString(this.SheetNO); string memo = this.txtRemark.Text.Contains(this.flagBody) ? this.txtRemark.Text : (this.txtRemark.Text + this.flagBody); t_pm_sheet_master _master = new t_pm_sheet_master(); _master.trans_no = "+"; _master.sheet_no = SheetNO; _master.trans_no = "YH"; _master.d_branch_no = Gattr.BranchNo; _master.branch_no = txtdBranchNO.Text.Trim(); _master.oper_id = Gattr.OperId; _master.valid_date = ExtendUtility.Instance.ParseToDateTime(ExtendUtility.Instance.ParseToDateTime(dateValid.Text.Trim()).ToString(LL.Common.GobalStaticString.DATE_FORMAT)); _master.memo = memo; if (istj) { _master.order_status = "0";//等待提交 } else { _master.order_status = "t"; } List <t_pm_sheet_master> _masters = new List <t_pm_sheet_master>(); _masters.Add(_master); string master1 = JsonUtility.Instance.ObjectToJson <t_pm_sheet_master>(_masters); string detail1 = JsonUtility.Instance.ObjectToJson <t_pm_sheet_detail>(_details); Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("master", master1); _dic.Add("detail", detail1); if (string.IsNullOrEmpty(this.SheetNO))//新增 { _dic.Add("add", "add"); } else { _dic.Add("add", "edit"); _dic.Add("sheet_no", SheetNO); } string errorMessage = string.Empty; string result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Addpsheet", _dic, ref isok, ref errorMessage); if (isok) { if (result != "-10" && result != "-20") { if (result != "-1" && result != "0" && result != "-2" && result != "404") { if (string.IsNullOrEmpty(this.SheetNO))//新增 { this.SheetNO = result; this.txtSheetNO.Text = result; } MessageBox.Show("保存成功", Gattr.AppTitle); if (istj) { this.btnSave.Enabled = false; this.btnDel.Enabled = false; this.btnDelAll.Enabled = false; this.btnSelectBranch.Enabled = false; this.btnApprove.Enabled = false; this.btnSelectItem.Enabled = false; this.dgvItemList.Enabled = false; } } else { string error = ""; switch (result) { case "-1": error = "记录不存在"; break; case "-2": error = "保存异常"; break; case "404": error = "提交出错"; break; default: error = "保存失败"; break; } MessageBox.Show(error, Gattr.AppTitle); } } else { if (result == "-10") { //参数错误 MessageBox.Show("参数错误", Gattr.AppTitle); } else { //禁止操作 MessageBox.Show("禁止操作", Gattr.AppTitle); } } } else { MessageBox.Show(errorMessage, Gattr.AppTitle); } } }
/// <summary> /// 挂单流水号 /// </summary> /// <returns></returns> public int GetMaxPendingOrderFlowNo() { return(Gfunc.TypeToInt(base._dal.GetMaxPendingOrderFlow(), 0)); }