public Object BillCodeConfigSave(string parameters) { ParameterHelper ph = new ParameterHelper(parameters); string template = ph.GetParameterValue <string>("template"); using (DBHelper db = new DBHelper()) { //获取编号配置 var config = db.FirstOrDefault("select * from billconfig where content->>'billname'='" + billname + "'"); if (config == null) { TableModel billconfig = new TableModel(); billconfig.content = new JObject(); billconfig.content.Add("billcodetemplate", template); db.Add("billconfig", billconfig); } else { config.content["billcodetemplate"] = template; db.Edit("billconfig", config); } db.SaveChanges(); } return(new { message = "ok", newcode = BillHelper.GetBillCode(billname) }); }
public Object Init(string parameters) { string billcode = BillHelper.GetBillCode(billname); JObject content = new JObject(); content.Add("billcode", billcode); content.Add("billname", billname); content.Add("billdate", DateTime.Now.ToString("yyyy-MM-dd")); DBHelper db = new DBHelper(); var option = db.First("select * from option"); int digit = 2; bool noeditbillcode = option.content["noeditbillcode"] == null ? false : option.content.Value <bool>("noeditbillcode"); bool noeditbilldate = option.content["noeditbilldate"] == null ? false : option.content.Value <bool>("noeditbilldate"); return(new { content = content, makername = PluginContext.Current.Account.Name, digit = digit, noeditbillcode = noeditbillcode, noeditbilldate = noeditbilldate }); }
public Object GetBillCodeTemplate(string parameters) { ParameterHelper ph = new ParameterHelper(parameters); string billname = ph.GetParameterValue <string>("billname"); return(new { template = BillHelper.GetBillCodeTemplate(billname) }); }
public Object Copy(string parameters) { ParameterHelper ph = new ParameterHelper(parameters); int id = ph.GetParameterValue <int>("id"); using (DBHelper db = new DBHelper()) { var bill = db.First("bill", id); bill.id = 0; bill.content["billcode"] = BillHelper.GetBillCode(bill.content.Value <string>("billname"), db); bill.content["billdate"] = DateTime.Now.ToString("yyyy-MM-dd"); bill.content["makerid"] = PluginContext.Current.Account.Id; bill.content["createtime"] = DateTime.Now; bill.content["auditstatus"] = 0; bill.content.Remove("auditorid"); bill.content.Remove("audittime"); bill.content.Remove("abort"); foreach (var item in bill.content.Value <JArray>("details").Values <JObject>()) { item.Remove("deliveryqty"); item["uuid"] = Guid.NewGuid().ToString("N"); } db.Add("bill", bill); db.SaveChanges(); } return(new { message = "ok" }); }
private void refreshDataView() // binding source change { consumeNum = 0; foreach (var detail in details_Num) { ArrayList goodNum = detail.Value; goodInfo temp = new goodInfo(detail.Key, Convert.ToDouble(goodNum[0]), (int)goodNum[1]); consumeNum += temp.tPrice; goodsList.Add(temp); //BindingList<goodInfo> temp = if (Items_Details.InvokeRequired) { Action listDel = () => { bs.DataSource = new BindingList <goodInfo>(goodsList); Items_Details.Refresh(); }; Items_Details.Invoke(listDel); } else { bs.DataSource = new BindingList <goodInfo>(goodsList); Items_Details.Refresh(); } if (Cost_Text.InvokeRequired) { Action <string> CostDel = (x) => { Cost_Text.Text = x.ToString(); }; Cost_Text.Invoke(CostDel, consumeNum.ToString()); } else { Cost_Text.Text = consumeNum.ToString(); } } double bal = meb.balance - consumeNum; if (bal < 0) { MessageBox.Show("余额不足"); return; } if (billNumber == "") { billNumber = InStock.getSoldBillNumber(); billNumber = BillHelper.getNextBillNumber(billNumber); } foreach (goodDetail goodTemp in goodsDetailList) { ArrayList detail = details_Num[goodTemp.name]; InStock.updateMemCostDetail(new costInfo(meb.ID, goodTemp.ID, DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(), billNumber, Convert.ToInt32(detail[1]), Convert.ToDouble(detail[0]) / Convert.ToInt32(detail[1]), Convert.ToDouble(detail[0]))); } InStock.updateMemBalance(meb.ID, bal); //setUserData(bal.ToString()); }
public Object Init(string parameters) { string billcode = BillHelper.GetBillCode(billname); JObject content = new JObject(); content.Add("billcode", billcode); content.Add("billname", billname); content.Add("billdate", DateTime.Now.ToString("yyyy-MM-dd")); DBHelper db = new DBHelper(); var billconfig = db.FirstOrDefault("select * from billconfig where content->>'billname'='" + billname + "'"); if (billconfig == null) { billconfig = new TableModel() { id = 0, content = new JObject() }; billconfig.content.Add("billname", billname); billconfig.content.Add("taxformat", false); billconfig.content.Add("discountformat", false); billconfig.content.Add("taxrate", 0); billconfig.content.Add("showstandard", false); billconfig.content.Add("showtype", false); billconfig.content.Add("showunit", false); billconfig.content.Add("showstorage", false); billconfig.content.Add("showarea", false); billconfig.content.Add("showbarcode", false); billconfig.content.Add("keepemployeeandstock", true); } var option = db.First("select * from option"); int digit = option.content["digit"] == null ? 2 : option.content.Value <int>("digit"); bool noeditbillcode = option.content["noeditbillcode"] == null ? false : option.content.Value <bool>("noeditbillcode"); bool noeditbilldate = option.content["noeditbilldate"] == null ? false : option.content.Value <bool>("noeditbilldate"); bool strictordermanage = option.content.Value <bool>("strictordermanage"); bool showcost = PluginContext.Current.Account.IsAllowed("showcost"); return(new { content = content, makername = PluginContext.Current.Account.Name, billconfig = billconfig, digit = digit, noeditbillcode = noeditbillcode, noeditbilldate = noeditbilldate, strictordermanage = strictordermanage, showcost = showcost }); }
public Object PurchaseSupplementSave(string parameters) { ParameterHelper ph = new ParameterHelper(parameters); int vendorid = ph.GetParameterValue <int>("vendorid"); string products = ph.GetParameterValue <string>("products"); TableModel purchaseorder = new TableModel() { id = 0, content = new JObject() }; using (DBHelper db = new DBHelper()) { var stock = db.FirstOrDefault("select * from stock where coalesce(content->>'stop','')=''"); if (stock == null) { return(new { message = StringHelper.GetString("请在基础资料中至少添加一个仓库!") }); } purchaseorder.content.Add("makerid", PluginContext.Current.Account.Id); purchaseorder.content.Add("employeeid", PluginContext.Current.Account.Id); purchaseorder.content.Add("billname", "purchaseorder"); purchaseorder.content.Add("billdate", DateTime.Now.ToString("yyyy-MM-dd")); purchaseorder.content.Add("billcode", BillHelper.GetBillCode("purchaseorder", db)); purchaseorder.content.Add("stockid", stock.id); purchaseorder.content.Add("createtime", DateTime.Now); purchaseorder.content.Add("attachments", new JArray()); purchaseorder.content.Add("vendorid", vendorid); JArray details = new JArray(); var billconfig = db.FirstOrDefault("select * from billconfig where content->>'billname'='purchaseorder'"); decimal taxrate = 0; if (billconfig != null && billconfig.content.Value <bool>("taxformat")) { taxrate = billconfig.content.Value <decimal>("taxrate"); } string[] ss = products.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in ss) { string[] ss2 = s.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); JObject detail = new JObject(); decimal qty = Convert.ToDecimal(ss2[1]); decimal taxprice = Convert.ToDecimal(ss2[2]); detail.Add("uuid", Guid.NewGuid().ToString("N")); detail.Add("productid", Convert.ToInt32(ss2[0])); detail.Add("qty", qty); detail.Add("taxprice", taxprice); detail.Add("taxtotal", taxprice * qty); detail.Add("taxrate", taxrate); detail.Add("discountrate", 100); detail.Add("discountprice", taxprice); detail.Add("discounttotal", taxprice * qty); detail.Add("price", taxprice / (100M + taxrate) * 100M); detail.Add("total", taxprice * qty / (100M + taxrate) * 100M); details.Add(detail); } purchaseorder.content.Add("details", details); db.Add("bill", purchaseorder); db.SaveChanges(); } return(new { message = "ok" }); }