using cuidian.Sql; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using TempDbToUfida; using TempDbToUfida.OpenApi; using WangToTempDb; using YiLvRunFrom.BLL; using YiLvRunFrom.Dal; namespace YiLvRunFrom { public delegate List OneDel(string one); public delegate bool BoolDel(); public partial class Form2 : Form { public Form2() { InitializeComponent(); _init(); } private void _init() { //comboBox1.Items.Add("供应商"); //comboBox1.Items.Add("仓库"); comboBox1.Items.Add("存货"); comboBox1.Items.Add("其他入库"); comboBox1.Items.Add("其他出库"); comboBox1.Items.Add("采购订单"); comboBox1.Items.Add("采购入库"); comboBox1.Items.Add("采购退货"); comboBox1.Items.Add("销售订单"); comboBox1.Items.Add("销售出库"); comboBox1.Items.Add("库存"); } private void LoadList() { dgvList.AutoGenerateColumns = false; dgvList.DataSource = new WdtLosBll().GetList(); } private List LoadList(string typeStr) { dgvList.AutoGenerateColumns = false; List wdtList = new WdtLosBll().GetList(typeStr); dgvList.DataSource = wdtList; return wdtList; } //key:start_time value:2019-08-27 00:00:01 key:end_time value:2019 - 08 - 27 22: 29:41 key:page_no value:0 key:page_size value:100 、 //string[] arrs = str.Split(new string[] { "key:", "value:" }, StringSplitOptions.RemoveEmptyEntries); private void button1_Click(object sender, EventArgs e) { IUpLoad upload = null; IDownLoad download = null; Dictionary args = new Dictionary(); if (comboBox1.SelectedItem == null) { MessageBox.Show("请选择数据类型");//OneDel oneDel =LoadList; } else if (comboBox1.SelectedItem.ToString() == "存货") { upload = new InventoryUpLoad(); download = new DownLoadInventory(); OneDel oneDel = LoadList; DisposeLogs(oneDel, "存货", upload, download, args, () => (Convert.ToDateTime(args["start_time"]) > Convert.ToDateTime(args["end_time"])) || (Convert.ToDateTime(args["end_time"]) > DateTime.Now) || (Convert.ToDateTime(args["end_time"]).Subtract(Convert.ToDateTime(args["start_time"])).TotalDays > 30)); } else if (comboBox1.SelectedItem.ToString() == "其他入库") { upload = new StockinUpLoad(); download = new DownLoadOtherin(); OneDel oneDel = LoadList; DisposeLogs(oneDel, "其他入库", upload, download, args, () => (Convert.ToDateTime(args["start_time"]) > Convert.ToDateTime(args["end_time"])) || (Convert.ToDateTime(args["end_time"]) > DateTime.Now) || (Convert.ToDateTime(args["end_time"]).Subtract(Convert.ToDateTime(args["start_time"])).TotalDays > 30)); } else if (comboBox1.SelectedItem.ToString() == "其他出库") { upload = new StockoutUpLoad(); download = new DownLoadOtherout(); OneDel oneDel = LoadList; DisposeLogs(oneDel, "其他出库", upload, download, args, () => (Convert.ToDateTime(args["start_time"]) > Convert.ToDateTime(args["end_time"])) || (Convert.ToDateTime(args["end_time"]) > DateTime.Now) || (Convert.ToDateTime(args["end_time"]).Subtract(Convert.ToDateTime(args["start_time"])).TotalDays > 30)); } else if (comboBox1.SelectedItem.ToString() == "采购订单") { upload = new PO_PomainUpLoad(); download = new DownLoadPurchaseorder(); OneDel oneDel = LoadList; DisposeLogs(oneDel, "采购订单", upload, download, args, () => (Convert.ToDateTime(args["start_time"]) > Convert.ToDateTime(args["end_time"])) || (Convert.ToDateTime(args["end_time"]) > DateTime.Now) || (Convert.ToDateTime(args["end_time"]).Subtract(Convert.ToDateTime(args["start_time"])).TotalDays > 30)); } else if (comboBox1.SelectedItem.ToString() == "采购入库") { upload = new InvoiceItemaUpLoad(); download = new DownLoadPurchasein(); OneDel oneDel = LoadList; args["status"] = "60"; DisposeLogs(oneDel, "采购入库", upload, download, args, () => (Convert.ToDateTime(args["start_time"]) > Convert.ToDateTime(args["end_time"])) || (Convert.ToDateTime(args["end_time"]) > DateTime.Now) || (Convert.ToDateTime(args["end_time"]).Subtract(Convert.ToDateTime(args["start_time"])).TotalDays > 30)); } else if (comboBox1.SelectedItem.ToString() == "采购退货") { upload = new PurchaseUpLoad(); download = new DownLoadPurchasereturn(); OneDel oneDel = LoadList; DisposeLogs(oneDel, "采购退货", upload, download, args, () => (Convert.ToDateTime(args["start_time"]) > Convert.ToDateTime(args["end_time"])) || (Convert.ToDateTime(args["end_time"]) > DateTime.Now) || (Convert.ToDateTime(args["end_time"]).Subtract(Convert.ToDateTime(args["start_time"])).TotalDays > 30)); } else if (comboBox1.SelectedItem.ToString() == "销售出库") { upload = new DispatchListUpLoad(); download = new DownLoadReturnorder(); OneDel oneDel = LoadList; DisposeLogs(oneDel, "销售出库", upload, download, args, () => (Convert.ToDateTime(args["start_time"]) > Convert.ToDateTime(args["end_time"])) || (Convert.ToDateTime(args["end_time"]) > DateTime.Now) || (Convert.ToDateTime(args["end_time"]).Subtract(Convert.ToDateTime(args["start_time"])).TotalDays > 30)); } //else if (comboBox1.SelectedItem.ToString() == "销售订单") //{ // upload = new TradeUpLoad(); // download = new DownLoadSaleorder(); // OneDel oneDel = LoadList; // DisposeLogs(oneDel, "销售订单", upload, download, args, () => (Convert.ToDateTime(args["start_time"]) > Convert.ToDateTime(args["end_time"])) || (Convert.ToDateTime(args["end_time"]) > DateTime.Now) || (Convert.ToDateTime(args["end_time"]).Subtract(Convert.ToDateTime(args["start_time"])).TotalHours > 1)); //} else if(comboBox1.SelectedItem.ToString() == "库存") { MessageBox.Show("库存无需处理"); } } /// /// 委托处理错误日志类 /// /// /// /// /// private void DisposeLogs(OneDel one, string oneStr, IUpLoad upload, IDownLoad download, Dictionary args, BoolDel getFlag) { button1.Text = "正在处理" + oneStr; List inventoryList = one(oneStr); if (inventoryList.Count == 0) { MessageBox.Show("该数据类型没有遗漏及错误"); } else { //upload = new InventoryUpLoad(); //download = new DownLoadInventory(); List sysids = new List(); foreach (Model.WdtLogs item in inventoryList) { sysids.Add(item.SysId); string[] arrs = item.Args.Split(new string[] { "key:", "value:" }, StringSplitOptions.RemoveEmptyEntries); //时间中不能含有空格,convert用于去除空格,不可删2019-09-01 00:00:00 try { args["start_time"] = Convert.ToDateTime(arrs[5]).ToString(); //arrs[1]; args["end_time"] = Convert.ToDateTime(arrs[7]).ToString(); //arrs[3]; } catch { args["start_time"] = Convert.ToDateTime(arrs[1]).ToString(); //arrs[1]; args["end_time"] = Convert.ToDateTime(arrs[3]).ToString(); //arrs[3]; } if (getFlag()) { continue; } upload.UpLoad(args); if (oneStr == "销售出库") { IUpLoad uploadTwo = new DispatchListSendUpLoad(); uploadTwo.UpLoad(args); } } download.DownLoad(); string deleteStr = string.Join(",", sysids); TimeDal.deleteErr(deleteStr); //LoadList("存货"); one(oneStr); MessageBox.Show(oneStr + "处理成功"); button1.Text = "处理错误"; } } private void Form2_Load(object sender, EventArgs e) { LoadList(); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.SelectedItem.ToString() == "存货") { LoadList("存货"); } else if (comboBox1.SelectedItem.ToString() == "其他入库") { LoadList("其他入库"); } else if (comboBox1.SelectedItem.ToString() == "其他出库") { LoadList("其他出库"); } else if (comboBox1.SelectedItem.ToString() == "采购入库") { LoadList("采购入库"); } else if (comboBox1.SelectedItem.ToString() == "采购订单") { LoadList("采购订单"); } else if (comboBox1.SelectedItem.ToString() == "采购退货") { LoadList("采购退货"); } //else if (comboBox1.SelectedItem.ToString() == "销售订单") //{ // LoadList("销售订单"); //} else if (comboBox1.SelectedItem.ToString() == "销售出库") { LoadList("销售出库"); } else if (comboBox1.SelectedItem.ToString() == "库存") { LoadList("库存"); } } private void 删除ToolStripMenuItem_Click(object sender, EventArgs e) { foreach (DataGridViewRow dgvRow in dgvList.SelectedRows) { DbUtils.ExecuteNonQuery(string.Format("delete from wdtlogs where sysid='{0}'", dgvRow.Cells[0].Value), ConnectionUtils.Instance.GetConnection("TempDB")); //dgvList.Rows.Remove(dgvRow); } if (comboBox1.SelectedItem.ToString() != null) { LoadList(comboBox1.SelectedItem.ToString()); } else { MessageBox.Show("未选择数据类型"); } } private void dgvList_CellContentClick(object sender, DataGridViewCellEventArgs e) { } } }