123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- 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<Model.WdtLogs> 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<Model.WdtLogs> LoadList(string typeStr)
- {
- dgvList.AutoGenerateColumns = false;
- List<Model.WdtLogs> 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<string, string> args = new Dictionary<string, string>();
- 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("库存无需处理");
- }
- }
- /// <summary>
- /// 委托处理错误日志类
- /// </summary>
- /// <param name="one"></param>
- /// <param name="oneStr"></param>
- /// <param name="upload"></param>
- /// <param name="download"></param>
- private void DisposeLogs(OneDel one, string oneStr, IUpLoad upload, IDownLoad download, Dictionary<string, string> args, BoolDel getFlag)
- {
- button1.Text = "正在处理" + oneStr;
- List<Model.WdtLogs> inventoryList = one(oneStr);
- if (inventoryList.Count == 0)
- {
- MessageBox.Show("该数据类型没有遗漏及错误");
- }
- else
- {
- //upload = new InventoryUpLoad();
- //download = new DownLoadInventory();
- List<int> sysids = new List<int>();
- 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)
- {
- }
- }
- }
|