private string GenerateYhMasterData() { t_pm_sheet_master _master = new t_pm_sheet_master(); _master.sheet_no = "YH0041408160013"; _master.trans_no = "YH"; _master.branch_no = "003"; _master.d_branch_no = "004"; _master.oper_id = "1020"; _master.valid_date = ExtendUtility.Instance.ParseToDateTime(System.DateTime.Now.ToShortDateString()); _master.sheet_amt = 100.52M; _master.memo = "Test2333333333333333"; List <t_pm_sheet_master> _masters = new List <t_pm_sheet_master>(); _masters.Add(_master); string result = JsonUtility.Instance.ObjectToJson <t_pm_sheet_master>(_masters); return(result); }
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); } } }
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); } } }