/// <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); }
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); } }
/// <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); }
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 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 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; } } }
/// <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(); //} } }
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> /// 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 }
/// <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="payFlow">支付信息,此支付信息是拼合而成</param> /// <param name="isAdd">是否是增加支付信息</param> private void AddPayFow(t_pos_payflow payFlow, bool isAdd) { 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()); if (amount < 0M) { MessageBox.Show("金额必须大于等于零!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.txtAmount.SelectAll(); this.txtAmount.Focus(); } else if (amount > payFlow.sale_amount) { MessageBox.Show("金额值过大!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.txtAmount.SelectAll(); this.txtAmount.Focus(); } else { try { ListItem list = (ListItem)this.cbox_PayWay.SelectedItem; string key = list.Key; int index = key.IndexOf(']'); this._returnText = key.Substring(0, index).Substring(1); string flowNo = payFlow.flow_no; string pay_name = list.Key.Substring(list.Key.LastIndexOf("]") + 1); t_pos_payflow _pay = new t_pos_payflow(); if (isAdd) { _pay.flow_id = payFlow.flow_id + 1; _pay.oper_date = System.DateTime.Now.ToString("s"); _pay.com_flag = "0"; } else { _pay.flow_id = payFlow.flow_id; _pay.com_flag = "1"; } _pay.flow_no = flowNo; _pay.branch_no = payFlow.branch_no; if (_isF) { _pay.sale_way = "F"; } else { _pay.sale_way = "A"; } _pay.sale_amount = payFlow.sale_amount; _pay.pay_way = _returnText;//支付方式 _pay.oper_id = payFlow.oper_id; _pay.pos_id = payFlow.pos_id; _pay.pay_amount = amount; _pay.coin_rate = 1M; _pay.convert_amt = amount; _pay.memo = this.txtMemo.Text.Trim(); _pay.coin_type = _returnText; _pay.pay_name = pay_name; bool isOK = false; string message = string.Empty; if (isAdd) { isOK = Gattr.Bll.SaveNonTrading(_pay); message = "添加"; } else { Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); //flow_no,flow_id,pay_way,pay_name,pay_amount _dic.Add("flow_no", _pay.flow_no); _dic.Add("flow_id", _pay.flow_id); _dic.Add("pay_way", _pay.pay_way); _dic.Add("pay_name", _pay.pay_name); _dic.Add("pay_amount", _pay.pay_amount); string errorMessage = string.Empty; bool isok = false; string result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Updatepayflow", _dic, ref isok, ref errorMessage); message = "修改"; if (result == "1") { LoggerHelper.Log("MsmkLogger", flowNo + message + "接口Updatepayflow更新支付成功", LogEnum.SysLog); isOK = Gattr.Bll.UpdatePayFlowByFid(_pay); } else { LoggerHelper.Log("MsmkLogger", flowNo + message + "接口Updatepayflow更新失败", LogEnum.SysLog); isOK = false; } } if (isOK) { MessageBox.Show(message + "支付成功", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); LoggerHelper.Log("MsmkLogger", flowNo + message + "支付成功", LogEnum.SysLog); DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBox.Show(message + "支付失败!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); LoggerHelper.Log("MsmkLogger", flowNo + message + "支付失败", LogEnum.SysLog); } } catch { MessageBox.Show("调整支付方式失败!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); LoggerHelper.Log("MsmkLogger", "修改支付----调整支付方式失败", LogEnum.ExceptionLog); } } } } }
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> /// 提交反馈事件逻辑 /// </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); } }
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); } }
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); } } }
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> 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); } }
private void btnSearch_Click(object sender, EventArgs e) { 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 { //配置POS信息 BaseInfoService.Instance.BranchNO = Gattr.BranchNo; BaseInfoService.Instance.SheetNO = this.txtSheetNO.Text.Trim(); 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; } //接口参数 Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("branch_no", Gattr.BranchNo); _dic.Add("start", startDate.ToString()); _dic.Add("end", endDate.ToString()); _dic.Add("sheet_no", txtSheetNO.Text.Trim()); bool isok1 = true; string errorMessage = string.Empty; //参数提交 string result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Getmosheet", _dic, ref isok1, ref errorMessage); if (isok1) { if (result != "-10" && result != "-20" && result != "-2" && result != "-1") { //Json转换Table DataTable table = JsonUtility.Instance.JsonToDataTable(result); if (table != null && table.Rows.Count > 0) { this.dgvSheet.DataSource = table; } else { MessageBox.Show("没有找到数据", Gattr.AppTitle); } LoggerHelper.Log("MsmkLogger", System.DateTime.Now.ToString() + "【" + Gattr.OperId + "】查看收货单!", LogEnum.SysLog); } 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); } } } else { MessageBox.Show(errorMessage, Gattr.AppTitle); } } } catch (Exception exc) { throw exc; } } }