private void LaunchButton_Click(object sender, EventArgs e) { string errorMessage = CollectSourceData(out var data); if (String.IsNullOrEmpty(errorMessage)) { ProcessForm processForm = new ProcessForm(data); processForm.Show(); processForm.StartCalculation(); } else { MessageBox.Show(errorMessage); } }
private void btnUploadData_Click(object sender, EventArgs e) { if (_worker.IsBusy) { return; } if (PersonInfoList.Count == 0) { return; } if (MessageBox.Show("真的要上传吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { ProcessFormObj = new ProcessForm(); ProcessFormObj.Show(); ProcessFormObj.BringToFront(); btnUploadData.Enabled = false; _worker.RunWorkerAsync(); } }
// 上报已修改的信息 private void barUpdate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (!Utils.CheckUser()) { return; } try { //获取上报修改的数据 List <string> vinList = new List <string>(); this.gcCljbxx.DefaultView.PostEditor(); DataTable dt = (DataTable)this.gcCljbxx.DataSource; if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { bool result = false; bool.TryParse(dt.Rows[i]["check"].ToString(), out result); if (result) { string vin = String.Format("'{0}'", dt.Rows[i]["vin"]); vinList.Add(vin); } } } if (vinList == null || vinList.Count < 1) { MessageBox.Show("请选择要上报修改的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ReasonForm rf = new ReasonForm(); Utils.SetFormMid(rf); rf.Text = "修改原因"; rf.ShowDialog(); //Utils.Open("UPDATE"); if (rf.DialogResult == DialogResult.OK) { pf = new ProcessForm(); pf.Show(); // 发出修改 List <OperateResult> orList = this.ApplyParamMultiRows(vinList, rf.Reason); //FuelDataSysClient.FuelDataService.OperateResult sor = service.ApplyUpdate(Utils.userId, Utils.password, Utils.FuelInfoC2S(vbiList).ToArray(), "CATARC_CUSTOM_2012"); //OperateResult or = Utils.OperateResultS2C(sor); // 获取修改结果 List <string> vinsSucc = new List <string>(); List <NameValuePair> vinsFail = new List <NameValuePair>(); Dictionary <string, string> dSuccVinVid = new Dictionary <string, string>(); //Utils.getOperateResultVins(or, vinsSucc, vinsFail, dSuccVinVid); Utils.getOperateResultListVins(orList, vinsSucc, vinsFail, dSuccVinVid); string strSucc = "";// "备案号(VIN):返回码(VID)"; // 修改本地状态为“0:已上报” if (vinsSucc.Count > 0) { string strUpdate = ""; for (int i = 0; i < vinsSucc.Count; i++) { strUpdate += String.Format(",'{0}'", vinsSucc[i]); strSucc += String.Format("备案号(VIN):{0},\r反馈码(VID):{1}, \r成功 \r\n", vinsSucc[i], dSuccVinVid[vinsSucc[i]]); } //Utils.setStatusForUpload(strUpdate.Substring(1), "0"); //// 反馈码入库 //Utils.setVidForUpload(dSuccVinVid); Utils.setVidStatusForUpload(dSuccVinVid); // 刷新当前页面 this.searchLocal(); } string strFail = ""; if (vinsFail.Count > 0) { for (int i = 0; i < vinsFail.Count; i++) { strFail += String.Format("备案号(VIN):{0}, \r失败:\r\n{1} \r\n", vinsFail[i].Name, vinsFail[i].Value); } } string summary = string.Format("{0}条申请成功\r\n {1}条申请失败\r\n", vinsSucc.Count, vinsFail.Count); MessageForm mf = new MessageForm(String.Format("{0}{1} \n{2}", summary, strSucc, strFail)); Utils.SetFormMid(mf); mf.Text = "申请修改结果"; mf.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (pf != null) { pf.Close(); } //Utils.Close("UPDATE"); } }
//撤销 private void barRepeal_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (!Utils.CheckUser()) { return; } try { //获取撤销的数据 List <string> vinList = new List <string>(); this.gcCLJBXX.DefaultView.PostEditor(); DataTable dt = (DataTable)this.gcCLJBXX.DataSource; if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { bool result = false; bool.TryParse(dt.Rows[i]["check"].ToString(), out result); if (result) { string vin = (string)dt.Rows[i]["vin"]; vinList.Add(vin); } } } if (vinList == null || vinList.Count < 1) { MessageBox.Show("请选择要撤销的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string delReason = string.Empty; ReasonForm rf = new ReasonForm(); Utils.SetFormMid(rf); rf.Text = "撤销原因"; rf.ShowDialog(); if (rf.DialogResult == DialogResult.OK) { pf = new ProcessForm(); pf.Show(); delReason = rf.Reason; // 撤销 List <OperateResult> orList = ApplyParamMultiRows(vinList, delReason); // 获取撤销结果 List <string> vinsSucc = new List <string>(); List <NameValuePair> vinsFail = new List <NameValuePair>(); Dictionary <string, string> dSuccVinVid = new Dictionary <string, string>(); Utils.getOperateResultListVins(orList, vinsSucc, vinsFail, dSuccVinVid); string strSucc = "";// "备案号(VIN):返回码(VID)"; // 修改本地状态为“3:已撤销” if (vinsSucc.Count > 0) { string strUpdate = ""; for (int i = 0; i < vinsSucc.Count; i++) { strUpdate += String.Format(",'{0}'", vinsSucc[i]); strSucc += String.Format("备案号(VIN):{0},\r反馈码(VID):{1}, \r成功 \r\n", vinsSucc[i], dSuccVinVid[vinsSucc[i]]); } // 删除已撤销数据 DelteLocalData(strUpdate.Substring(1)); // 刷新当前页面 this.refrashCurrentPage(); } string strFail = ""; if (vinsFail.Count > 0) { for (int i = 0; i < vinsFail.Count; i++) { strFail += String.Format("备案号(VIN):{0},\r反馈码(VID):, \r失败:{1} \r\n", vinsFail[i].Name, vinsFail[i].Value); } } string summary = string.Format("{0}条申请成功\r\n {1}条申请失败\r\n", vinsSucc.Count, vinsFail.Count); MessageForm mf = new MessageForm(String.Format("{0}{1} \n{2}", summary, strSucc, strFail)); Utils.SetFormMid(mf); mf.Text = "申请撤销结果"; mf.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (pf != null) { pf.Close(); } } }
//油耗上报 private void barShangbao_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (!Utils.CheckUser()) { return; } try { //获取上报数据 List <string> vinList = new List <string>(); this.gcCLJBXX.DefaultView.PostEditor(); DataTable dt = (DataTable)this.gcCLJBXX.DataSource; if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { bool result = false; bool.TryParse(dt.Rows[i]["check"].ToString(), out result); if (result) { string vin = String.Format("'{0}'", dt.Rows[i]["vin"]); vinList.Add(vin); } } } if (vinList == null || vinList.Count < 1) { MessageBox.Show("请选择要上报的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } pf = new ProcessForm(); pf.Show(); // 上报 List <OperateResult> orList = ApplyParamMultiRows(vinList); // 获取上报结果 List <string> vinsSucc = new List <string>(); List <NameValuePair> vinsFail = new List <NameValuePair>(); Dictionary <string, string> dSuccVinVid = new Dictionary <string, string>(); Utils.getOperateResultListVins(orList, vinsSucc, vinsFail, dSuccVinVid); string strSucc = "";// "备案号(VIN):返回码(VID)"; // 修改本地状态为“0:已上报” if (vinsSucc.Count > 0) { string strUpdate = ""; for (int i = 0; i < vinsSucc.Count; i++) { strUpdate += String.Format(",'{0}'", vinsSucc[i]); strSucc += String.Format("备案号(VIN):{0},\r反馈码(VID):{1}, \r成功 \r\n", vinsSucc[i], dSuccVinVid[vinsSucc[i]]); } //// 反馈码入库 Utils.setVidStatusForUpload(dSuccVinVid); // 刷新当前页面 this.refrashCurrentPage(); } string strFail = ""; if (vinsFail.Count > 0) { for (int i = 0; i < vinsFail.Count; i++) { strFail += String.Format("备案号(VIN):{0},\r反馈码(VID):, \r失败: {1} \r\n", vinsFail[i].Name, vinsFail[i].Value); } } string summary = string.Format("{0}条上传成功\r\n {1}条上传失败\r\n", vinsSucc.Count, vinsFail.Count); MessageForm mf = new MessageForm(String.Format("{0}{1} \n{2}", summary, strFail, strSucc)); Utils.SetFormMid(mf); mf.Text = "上报结果"; mf.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (pf != null) { pf.Close(); } } }
public void IntegraCarteiraCliente() { ProcessForm processForm = new ProcessForm("", layout); processForm.Show(); List<CarteiraCliente> lCarteiraCliente = new List<CarteiraCliente>(); IEnumerable<String> streamRead = File.ReadLines(System.Environment.CurrentDirectory.ToString() + "\\config.txt"); var connection = streamRead.First(); using (OleDbConnection con = new OleDbConnection(connection)) { try { con.Open(); using (OleDbCommand commandCount = new OleDbCommand("SELECT COUNT(*) FROM CARTEIRA_CLIENTES ", con)) using (OleDbDataReader readerCount = commandCount.ExecuteReader()) { while (readerCount.Read()) { countRegister = readerCount.GetValue(0).ToString(); } } try { using (OleDbCommand command = new OleDbCommand("SELECT ID_DISTRIBUIDOR,ID_FV,ID_CLIENTE,DATA_PRIMEIRO_ATENDIMENTO,DATA_ULTIMO_ATENDIMENTO,VALOR_ULTIMA_VENDA,VALOR_PRIMEIRA_VENDA FROM CARTEIRA_CLIENTES ", con)) using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { CarteiraCliente carteiraCliente = new CarteiraCliente(); carteiraCliente.distribuidorId = reader.GetString(0); carteiraCliente.forcaDeVendaId = reader.GetString(1); carteiraCliente.clienteId = reader.GetString(2); carteiraCliente.dataPrimeiroAtendimento = reader.GetString(3); carteiraCliente.dataUltimoAtendimento = reader.GetString(4); carteiraCliente.ValorUltimaVenda = reader.GetString(5); carteiraCliente.valorPrimeiraVenda = reader.GetString(6); PostCarteiraCLiente(carteiraCliente); string msg = "Foram inseridos: " + lCarteiraCliente.Count().ToString() + " de " + countRegister + " registros"; processForm.writeMessage(msg); processForm.Enabled = false; processForm.Enabled = true; lCarteiraCliente.Add(carteiraCliente); } } con.Dispose(); } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); // MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); // MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } int countWrite = lCarteiraCliente.Count(); //MessageBox.Show("Foram inseridos " + countWrite.ToString() + " registros", "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); processForm.Close(); } }
public void IntegraTabelaPreço() { ProcessForm processForm = new ProcessForm("", layout); processForm.Show(); List<TabelaPreco> lTabelaPreco = new List<TabelaPreco>(); IEnumerable<String> streamRead = File.ReadLines(System.Environment.CurrentDirectory.ToString() + "\\config.txt"); var connection = streamRead.First(); using (OleDbConnection con = new OleDbConnection(connection)) { try { con.Open(); using (OleDbCommand commandCount = new OleDbCommand("SELECT COUNT(*) FROM TABELA_PRECO ", con)) using (OleDbDataReader readerCount = commandCount.ExecuteReader()) { while (readerCount.Read()) { countRegister = readerCount.GetValue(0).ToString(); } } try{ using (OleDbCommand command = new OleDbCommand("SELECT ID_DISTRIBUIDOR,SKU_PRODUTO,NOME_TABELA_PRECO,PREÇO_UNITARIO,QUANTIDADE_INICIAL,PREÇO_ESCALONADO FROM TABELA_PRECO", con)) using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { TabelaPreco tabelaPreco = new TabelaPreco(); tabelaPreco.distribuidorId = reader.GetString(0); tabelaPreco.produtoId = reader.GetString(1); tabelaPreco.nomeTabelaPreco = reader.GetString(2); tabelaPreco.precoUnitario = reader.GetString(3); tabelaPreco.quantidadeInicial = reader.GetString(4); tabelaPreco.precoEscalonado = reader.GetString(5); PostTabelaPreco(tabelaPreco); string msg = "Foram inseridos: " + lTabelaPreco.Count().ToString() + " de " + countRegister + " registros"; processForm.writeMessage(msg); processForm.Enabled = false; processForm.Enabled = true; lTabelaPreco.Add(tabelaPreco); } } con.Dispose(); } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); // MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } int countWrite = lTabelaPreco.Count(); //MessageBox.Show("Foram inseridos "+countWrite.ToString()+" registros", "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); processForm.Close(); }
private void btnUploadOT_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (!Utils.CheckUser()) { return; } try { //获取补传的数据 List <string> vinList = new List <string>(); this.gcCljbxx.DefaultView.PostEditor(); DataTable dt = (DataTable)this.gcCljbxx.DataSource; if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { bool result = false; bool.TryParse(dt.Rows[i]["check"].ToString(), out result); if (result) { string vin = String.Format("'{0}'", dt.Rows[i]["vin"]); vinList.Add(vin); } } } if (vinList == null || vinList.Count < 1) { MessageBox.Show("请选择要补传的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string delReason = string.Empty; ReasonForm rf = new ReasonForm(); Utils.SetFormMid(rf); rf.Text = "补传原因"; rf.ShowDialog(); //Utils.Open("INSERT_O"); if (rf.DialogResult == DialogResult.OK) { pf = new ProcessForm(); pf.Show(); // 补传 List <OperateResult> orList = this.applyOTParamMultiRows(vinList, rf.Reason); // 获取补传结果 List <string> vinsSucc = new List <string>(); List <NameValuePair> vinsFail = new List <NameValuePair>(); Dictionary <string, string> dSuccVinVid = new Dictionary <string, string>(); Utils.getOperateResultListVins(orList, vinsSucc, vinsFail, dSuccVinVid); string strSucc = "";// "备案号(VIN):返回码(VID)"; // 修改本地状态为“4:已申请补传” if (vinsSucc.Count > 0) { string strUpdate = ""; for (int i = 0; i < vinsSucc.Count; i++) { strUpdate += String.Format(",'{0}'", vinsSucc[i]); strSucc += String.Format("备案号(VIN):{0},\r反馈码(VID):{1}, \r成功 \r\n", vinsSucc[i], dSuccVinVid[vinsSucc[i]]); } //Utils.setStatusForUpload(strUpdate.Substring(1), "0"); //// 反馈码入库 //Utils.setVidForUpload(dSuccVinVid); Utils.setVidStatusForUpload(dSuccVinVid); // 刷新当前页面 this.searchLocal(); } string strFail = ""; if (vinsFail.Count > 0) { for (int i = 0; i < vinsFail.Count; i++) { strFail += String.Format("备案号(VIN):{0},\r反馈码(VID):, \r失败: {1} \r\n", vinsFail[i].Name, vinsFail[i].Value); } } string summary = string.Format("{0}条补传成功\r\n {1}条补传失败\r\n", vinsSucc.Count, vinsFail.Count); MessageForm mf = new MessageForm(String.Format("{0}{1} \n{2}", summary, strSucc, strFail)); Utils.SetFormMid(mf); mf.Text = "补传结果"; mf.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (pf != null) { pf.Close(); } //关端口 //Utils.Close("INSERT_O"); } }
public void IntegraForcaDeVenda() { ProcessForm processForm = new ProcessForm("", layout); processForm.Show(); List<ForcaDeVenda> lForcaDeVenda = new List<ForcaDeVenda>(); IEnumerable<String> streamRead = File.ReadLines(System.Environment.CurrentDirectory.ToString() + "\\config.txt"); var connection = streamRead.First(); using (OleDbConnection con = new OleDbConnection(connection)) { try { con.Open(); using (OleDbCommand commandCount = new OleDbCommand("SELECT COUNT(*) FROM FORCA_VENDAS", con)) using (OleDbDataReader readerCount = commandCount.ExecuteReader()) { while (readerCount.Read()) { countRegister = readerCount.GetValue(0).ToString(); } } try{ using (OleDbCommand command = new OleDbCommand("SELECT ID_FV,ID_DISTRIBUIDOR,AREA_ATUACAO_FV,TIPO_FV,NOME_FV,EMAIL_FV,TEL_FV FROM FORCA_VENDAS", con)) using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { ForcaDeVenda forcaDeVenda = new ForcaDeVenda(); forcaDeVenda.id = reader.GetString(0); forcaDeVenda.distribuidorId = reader.GetString(1); forcaDeVenda.areaAtuacao = reader.GetString(2); forcaDeVenda.tipo = reader.GetString(3); forcaDeVenda.nome = reader.GetString(4); forcaDeVenda.email = reader.GetString(5); forcaDeVenda.telefone = reader.GetString(6); PostForcaDeVenda(forcaDeVenda); string msg = "Foram inseridos: " + lForcaDeVenda.Count().ToString() +" de "+countRegister+ " registros"; processForm.writeMessage(msg); processForm.Enabled = false; processForm.Enabled = true; lForcaDeVenda.Add(forcaDeVenda); } } con.Dispose(); } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } int countWrite = lForcaDeVenda.Count(); //MessageBox.Show("Foram inseridos "+countWrite.ToString()+" registros", "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); processForm.Close(); }
// 保时捷——导出Excel private void extractDataAndExport() { ProcessForm pf = new ProcessForm(); pf.Show(); //获取显示的车辆型号和日期信息 CafcService.StatisticsData[] dataSource = (CafcService.StatisticsData[]) this.gcStatistic.DataSource; int total = 0; foreach (CafcService.StatisticsData sd in dataSource) { total += sd.Sl; } pf.TotalMax = total; pf.ShowProcessBar(); //根据型号和日期(需要把开始日期和结束日期设为月份的第一天和最后一天)从服务器获取车型详细参数 List <FuelDataService.VehicleBasicInfo> listVB = new List <FuelDataService.VehicleBasicInfo>(); string startTime = this.dtStartTime.Text.Trim(); string endTime = this.dtEndTime.Text.Trim(); int pageCount = 1; while (true) { try { FuelDataService.VehicleBasicInfo[] fuelData = Utils.service.QueryUploadedFuelData(Utils.userId, Utils.password, pageCount, 500, string.Empty, String.Empty, string.Empty, string.Empty, startTime, endTime, "MANUFACTURE_TIME"); if (fuelData != null) { if (fuelData.Length == 0) { break; } listVB.AddRange(fuelData); pageCount++; pf.progressBarControl1.Properties.Step = fuelData.Length; pf.progressBarControl1.PerformStep(); Application.DoEvents(); } else { break; } } catch (WebException ex) { MessageBox.Show("请本地检测网络"); return; } } pf.Close(); //} if (listVB.Count == 0) { return; } //转换成为本地结构 List <VehicleBasicInfo> listConvertedVB = Utils.FuelInfoS2C(listVB.ToArray()); //将信息转化成datatable然后导出到excel当中 DataTable dtOutput = new DataTable(); String[] header = new String[] { "VIN", "CLXH", "TYMC", "RLLX", "EDZK", "ZWPS", "BSQXS", "ZCZBZL", "CLZZRQ", "ZHGKRLXHL", "LJ", "LTGG", "UPDATETIME" }; foreach (String s in header) { dtOutput.Columns.Add(s); } foreach (VehicleBasicInfo vb in listConvertedVB) { DataRow dr = dtOutput.NewRow(); foreach (DataColumn dc in dtOutput.Columns) { String columnName = dc.ColumnName; bool found = false; PropertyInfo[] properties = new VehicleBasicInfo().GetType().GetProperties(); foreach (PropertyInfo pi in properties) { if (pi.Name.Equals(columnName, StringComparison.OrdinalIgnoreCase)) { object result = pi.GetValue(vb, null); if (result is DateTime) { DateTime dt = (DateTime)result; dr[columnName] = dt.ToString("yyyy-MM-dd"); } else { dr[columnName] = pi.GetValue(vb, null); } found = true; break; } } if (!found) { RllxParamEntity[] rllxParams = vb.EntityList; if (rllxParams == null || rllxParams.Length == 0) { continue; } foreach (RllxParamEntity rpe in rllxParams) { if (rpe.Param_Code.Contains(columnName)) { dr[columnName] = rpe.Param_Value; break; } } } } dtOutput.Rows.Add(dr); } PorscheUtils utils = new PorscheUtils(true); utils.ExportExcel(dtOutput, this, PorscheUtils.CLMXExport); }
public void IntegraFormaDePagamento() { ProcessForm processForm = new ProcessForm("", layout); processForm.Show(); List<FormaDePagamento> lFormaDePagamento = new List<FormaDePagamento>(); IEnumerable<String> streamRead = File.ReadLines(System.Environment.CurrentDirectory.ToString() + "\\config.txt"); var connection = streamRead.First(); using (OleDbConnection con = new OleDbConnection(connection)) { try { con.Open(); using (OleDbCommand commandCount = new OleDbCommand("SELECT COUNT(*) FROM FORMA_PAGAMENTO ", con)) using (OleDbDataReader readerCount = commandCount.ExecuteReader()) { while (readerCount.Read()) { countRegister = readerCount.GetValue(0).ToString(); } } try{ using (OleDbCommand command = new OleDbCommand("SELECT ID_FORMA_PAGAMENTO,ID_DISTRIBUIDOR,DESC_FORMA_PAGAMENTO,FLAG_ATIVO_FORMA_PAGAMENTO FROM FORMA_PAGAMENTO", con)) using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { FormaDePagamento formaDePagamento = new FormaDePagamento(); formaDePagamento.id = reader.GetString(0); formaDePagamento.distribuidorId = reader.GetString(1); formaDePagamento.formaDePagamento = reader.GetString(2); formaDePagamento.flagAtivo = reader.GetString(3); PostFormaDePagamento(formaDePagamento); string msg = "Foram inseridos: " + lFormaDePagamento.Count().ToString() + " de "+countRegister+" registros"; processForm.writeMessage(msg); processForm.Enabled = false; processForm.Enabled = true; lFormaDePagamento.Add(formaDePagamento); } } con.Dispose(); } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } int countWrite = lFormaDePagamento.Count(); //MessageBox.Show("Foram inseridos "+countWrite.ToString()+" registros", "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); processForm.Close(); }
//保时捷汇总导出线程方法 public void porscheExport() { try { ProcessForm pf = new ProcessForm(); pf.Show(); //获取显示的产品型号和日期信息 CafcService.FuelCAFCDetails[] dataSource = (CafcService.FuelCAFCDetails[]) this.gcDetail.DataSource; int total = 0; foreach (CafcService.FuelCAFCDetails sd in dataSource) { total += sd.Sl_hs; } pf.TotalMax = total; pf.ShowProcessBar(); //根据型号和日期(需要把开始日期和结束日期设为月份的第一天和最后一天)从服务器获取车型详细参数 List <FuelDataService.VehicleBasicInfo> listVB = new List <FuelDataService.VehicleBasicInfo>(); string startTime = this.dtStartTime.Text.Trim(); string endTime = this.dtEndTime.Text.Trim(); int pageCount = 1; while (true) { try { FuelDataService.VehicleBasicInfo[] fuelData = Utils.service.QueryUploadedFuelData(Utils.userId, Utils.password, pageCount, 500, string.Empty, String.Empty, string.Empty, string.Empty, startTime, endTime, "MANUFACTURE_TIME"); if (fuelData != null) { if (fuelData.Length == 0) { break; } listVB.AddRange(fuelData); pageCount++; pf.progressBarControl1.Properties.Step = fuelData.Length; pf.progressBarControl1.PerformStep(); Application.DoEvents(); } else { break; } } catch (WebException ex) { MessageBox.Show("请本地检测网络"); return; } } pf.Close(); if (listVB.Count == 0) { return; } //转换成为本地结构 List <HZDCModule> listHzdc = Utils.VehicleBasicInfoTo <HZDCModule>(listVB.ToArray()); PorscheUtils porscheUtils = new PorscheUtils(true, startTime); List <exportModel> getMBZResult = new List <exportModel>(); //对vin信息进行分组 var vehicleBasicInfoGroupResult = (from t in listHzdc group t by new { t.ClXH, t.TYMC, t.ZHGKRLXHL, t.RLLX, t.ZCZBZL, t.BSQXS, t.ZWPS, t.EDZK } into g select new { g.Key.ClXH, g.Key.BSQXS, g.Key.EDZK, g.Key.RLLX, g.Key.TYMC, g.Key.ZCZBZL, g.Key.ZHGKRLXHL, g.Key.ZWPS, SL = g.Count() }).ToList(); if (Convert.ToDateTime(startTime).Year < 2016) { getMBZResult = (from s in vehicleBasicInfoGroupResult select new exportModel { bsqxs = s.BSQXS, clxh = s.ClXH, edzk = s.EDZK, rllx = s.RLLX, tymc = s.TYMC, zczbzl = Convert.ToInt32(s.ZCZBZL), zhgkrlxhlmbz = Convert.ToDecimal((from t in porscheUtils.dtTargetFuel.AsEnumerable() where (s.BSQXS.Equals("MT") ? "MT" : "OT").Equals(t.Field <string>("BSQXS")) && (Convert.ToInt32(s.ZWPS) < 3 ? "2" : "3").Equals(t.Field <string>("ZWPS")) && Convert.ToDouble(s.ZCZBZL) > t.Field <double>("MIN_ZCZBZL") && Convert.ToDouble(s.ZCZBZL) <= t.Field <double>("MAX_ZCZBZL") select t.Field <string>("TGT_ZHGKRLXHL")).FirstOrDefault()), zhgkrlxhl = Convert.ToDecimal(s.ZHGKRLXHL), zwps = s.ZWPS, sl = s.SL, }).ToList(); } else { getMBZResult = (from s in vehicleBasicInfoGroupResult select new exportModel { bsqxs = s.BSQXS, clxh = s.ClXH, edzk = s.EDZK, rllx = s.RLLX, tymc = s.TYMC, zczbzl = Convert.ToInt32(s.ZCZBZL), zhgkrlxhlmbz = Convert.ToDecimal((from t in porscheUtils.dtTargetFuel.AsEnumerable() where (Convert.ToInt32(s.ZWPS) < 3 ? "2" : "3").Equals(t.Field <string>("ZWPS")) && Convert.ToDouble(s.ZCZBZL) > t.Field <double>("MIN_ZCZBZL") && Convert.ToDouble(s.ZCZBZL) <= t.Field <double>("MAX_ZCZBZL") select t.Field <string>("TGT_ZHGKRLXHL")).FirstOrDefault()), zhgkrlxhl = Convert.ToDecimal(s.ZHGKRLXHL), zwps = s.ZWPS, sl = s.SL, }).ToList(); } var vinGroupResult = (from s in getMBZResult group s by s.clxh into result select new { clxh = result.First().clxh, rdzhgkrlxhl = result.Max(s => s.zhgkrlxhl), rdzhgkrlxhlmbz = result.Min(s => s.zhgkrlxhlmbz) }).ToList(); var allInfoReadyResult = (from s1 in getMBZResult join s2 in vinGroupResult on s1.clxh equals s2.clxh select new { bsqxs = s1.bsqxs.ToString(), clxh = s1.clxh.ToString(), edzk = s1.edzk.ToString(), rllx = s1.rllx.ToString(), tymc = s1.tymc.ToString(), zczbzl = Convert.ToInt16(s1.zczbzl), zhgkrlxhlmbz = Convert.ToDecimal(s1.zhgkrlxhlmbz), zhgkrlxhl = Convert.ToDecimal(s1.zhgkrlxhl), zwps = s1.zwps.ToString(), rdzhgkrlxhl = s2.rdzhgkrlxhl, rdzhgkrlxhlmbz = s2.rdzhgkrlxhlmbz, sl = s1.sl, }).ToList(); //将信息转化成datatable然后导出到excel当中 DataTable dtOutput = new DataTable(); String[] header = new String[] { "CLXH", "TYMC", "SL;int", "ZHGKRLXHL;decimal", "RDZHGKRLXHL;decimal", "SL*ZHGKRLXHL;decimal", "SL*RDZHGKRLXHL;decimal", "RLLX", "ZCZBZL;int", "BSQXS", "ZWPS", "EDZK", "ZHGKRLXHLMBZ;decimal", "RDZHGKRLXHLMBZ;decimal", "SL*ZHGKRLXHLMBZ;decimal", "SL*RDZHGKRLXHLMBZ;decimal" }; foreach (String s in header) { String type = "string", expression = ""; String[] expGroup = s.Split(new String[] { ";" }, StringSplitOptions.RemoveEmptyEntries); if (expGroup.First().Contains("*")) { expression = expGroup.First().Replace("*", " * "); } if (expGroup.Length > 1) { type = expGroup.Last(); } dtOutput.Columns.Add(expGroup.First(), Utils.GetTypeByString(type), expression); } foreach (var vb in allInfoReadyResult) { DataRow dr = dtOutput.NewRow(); foreach (DataColumn dc in dtOutput.Columns) { String columnName = dc.ColumnName; bool found = false; PropertyInfo[] properties = vb.GetType().GetProperties(); foreach (PropertyInfo pi in properties) { if (pi.Name.Equals(columnName, StringComparison.OrdinalIgnoreCase)) { object result = pi.GetValue(vb, null); if (result is DateTime) { DateTime dt = (DateTime)result; dr[columnName] = dt.ToString("yyyy-MM-dd"); } else { dr[columnName] = pi.GetValue(vb, null); } found = true; break; } } } dtOutput.Rows.Add(dr); } if (Convert.ToDateTime(startTime).Year < 2016) { porscheUtils.ExportExcel(dtOutput, this, PorscheUtils.HZBGExport); } else { porscheUtils.ExportExcel(dtOutput, this, PorscheUtils.HZBGExport_New); } } catch (Exception ex) { MessageBox.Show("导出失败:" + ex.Message + "\r\n" + ex.StackTrace, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void IntegraEnderecoCliente() { ProcessForm processForm = new ProcessForm("0", layout); processForm.Show(); List<EnderecoCliente> lEnderecoCliente = new List<EnderecoCliente>(); IEnumerable<String> streamRead = File.ReadLines(System.Environment.CurrentDirectory.ToString() + "\\config.txt"); var connection = streamRead.First(); using (OleDbConnection con = new OleDbConnection(connection)) { try { con.Open(); using (OleDbCommand commandCount = new OleDbCommand("SELECT COUNT(*) FROM ENDERECO_CLIENTES ", con)) using (OleDbDataReader readerCount = commandCount.ExecuteReader()) { while (readerCount.Read()) { countRegister = readerCount.GetValue(0).ToString(); } } try{ using (OleDbCommand command = new OleDbCommand("SELECT ID_END_CLIENTE,ID_DISTRIBUIDOR,ID_CLIENTE,COD_MUNICIPIO_IBGE_CLIENTE,RUA_END_CLIENTE,NUMERO_END_CLIENTE,COMPLEMENTO_END_CLIENTE,CEP_END_CLIENTE,BAIRRO_END_CLIENTE,MUNICIPIO_END_CLIENTE,UF_END_CLIENTE,TEL_END_CLIENTE,EMAIL_END_CLIENTE FROM ENDERECO_CLIENTES", con)) using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { EnderecoCliente enderecoCliente = new EnderecoCliente(); enderecoCliente.id = reader.GetString(0); enderecoCliente.distribuidorId = reader.GetString(1); enderecoCliente.clienteId = reader.GetString(2); enderecoCliente.codigoMunicipioIBGE = reader.GetString(3); enderecoCliente.cep = reader.GetString(4); enderecoCliente.bairro = reader.GetString(5); enderecoCliente.municipio = reader.GetString(6); enderecoCliente.uf = reader.GetString(7); enderecoCliente.telefone = reader.GetString(8); enderecoCliente.email = reader.GetString(9); PostEnderecoCliente(enderecoCliente); string msg = "Foram inseridos: " + lEnderecoCliente.Count().ToString() + " de " + countRegister + " registros"; processForm.writeMessage(msg); processForm.Enabled = false; processForm.Enabled = true; lEnderecoCliente.Add(enderecoCliente); } } con.Dispose(); } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } int countWrite = lEnderecoCliente.Count(); //MessageBox.Show("Foram inseridos "+countWrite.ToString()+" registros", "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); processForm.Close(); }
public void IntegraProduto() { ProcessForm processForm = new ProcessForm("", layout); processForm.Show(); List<Produto> lProduto = new List<Produto>(); IEnumerable<String> streamRead = File.ReadLines(System.Environment.CurrentDirectory.ToString() + "\\config.txt"); var connection = streamRead.First(); using (OleDbConnection con = new OleDbConnection(connection)) { try { con.Open(); using (OleDbCommand commandCount = new OleDbCommand("SELECT COUNT(*) FROM PRODUTOS", con)) using (OleDbDataReader readerCount = commandCount.ExecuteReader()) { while (readerCount.Read()) { countRegister = readerCount.GetValue(0).ToString(); } } try{ using (OleDbCommand command = new OleDbCommand("SELECT SKU_PRODUTO,NOME_PRODUTO,ID_DISTRIBUIDOR,MARCA,PRODUTO,TIER,CLASSE_PRODUTO,SKU_CHEVRON,DESC_SKU_CHEVRON,COD_PRODUTO_EAN13,NCM_PRODUTO,EMBALAGEM,VOLUME_UNITARIO_PRODUTO,FLAG_ATIVO_PRODUTO FROM PRODUTOS", con)) using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Produto produto = new Produto(); produto.id = reader.GetString(0); produto.nome = reader.GetString(1); produto.distribuidorId = reader.GetString(2); produto.marca = reader.GetString(3); produto.produto = reader.GetString(4); produto.tier = reader.GetString(5); produto.classe = reader.GetString(6); produto.chevronId = reader.GetString(7); produto.chevronDescricao = reader.GetString(8); produto.ean13 = reader.GetString(9); produto.ncm = reader.GetString(10); produto.embalagem = reader.GetString(11); produto.volumeUnitario = reader.GetString(12); produto.flagAtivo = reader.GetString(13); PostProduto(produto); string msg = "Foram inseridos: " + lProduto.Count().ToString() + " de " + countRegister + " registros"; processForm.writeMessage(msg); processForm.Enabled = false; processForm.Enabled = true; lProduto.Add(produto); } } con.Dispose(); } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } int countWrite = lProduto.Count(); //MessageBox.Show("Foram inseridos "+countWrite.ToString()+" registros", "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); processForm.Close(); }
public void IntegraFaturamento() { ProcessForm processForm = new ProcessForm("", layout); processForm.Show(); List<Faturamento> lFaturamento = new List<Faturamento>(); IEnumerable<String> streamRead = File.ReadLines(System.Environment.CurrentDirectory.ToString() + "\\config.txt"); var connection = streamRead.First(); using (OleDbConnection con = new OleDbConnection(connection)) { try { con.Open(); using (OleDbCommand commandCount = new OleDbCommand("SELECT COUNT(*) FROM FATURAMENTO ", con)) using (OleDbDataReader readerCount = commandCount.ExecuteReader()) { while (readerCount.Read()) { countRegister = readerCount.GetValue(0).ToString(); } } try { using (OleDbCommand command = new OleDbCommand("SELECT SKU_PRODUTO,ID_CLIENTE,ID_DISTRIBUIDOR,ID_FV,ID_FORMA_PAGAMENTO,ID_END_ENTREGA,ID_END_COBRANCA,QTD_ITEM_NF_FATURA,VALOR_UNITARIO_ITEM_NF_FATURA,VALOR_TOTAL_NF_FATURA,VALOR_BRUTO_ITEM_NF_FATURA,VALOR_DESCONTO_ITEM_NF_FATURA,VALOR_TOTAL_ITEM_NF_FATURA,VALOR_LIQUIDO_ITEM_NF_FATURA,VALOR_CUSTO_ITEM_NF_FATURA,QTD_LITROS_ITEM_NF_FATURA,NUM_NF_FATURA,SERIE_NF_FATURA,ITEM_NF_FATURA,CFOP_NF_FATURA,NATUREZA_OPERACAO_NF_FATURA,OBSERVACAO_NF_FATURA,DATA_NF_FATURA,FLAG_ITEM_CANCELADO,DATA_CANCELAMENTO,QUANTIDADE_CANCELADO,VALOR_FRETE_NF,VALOR_IPI_ITEM,VALOR_PIS_ITEM,VALOR_COFINS_ITEM,VALOR_ICMS_ITEM,VALOR_ICMS_ST_ITEM,VALOR_SEGURO_ITEM,VALOR_DESPESAS_EXTRA_ITEM,FLAG_FATURAMENTO_TP_ENTREGA FROM FATURAMENTO", con)) using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Faturamento faturamento = new Faturamento(); Validator valid = new Validator(); for(int i = reader.FieldCount-1; i>=0; i--){ if (!(i == 34 || i == 33 || i == 32 || i == 25 || i == 24 || i == 21)) { if (reader.IsDBNull(i)) { MessageBox.Show(i.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } faturamento.produtoId = reader.GetValue(0).ToString(); faturamento.clienteId = reader.GetString(1); faturamento.distribuidorId = reader.GetString(2); faturamento.forcaDeVendaId = reader.GetString(3); faturamento.formaDePagamentoId = reader.GetString(4); faturamento.enderecoEntregaId = reader.GetString(5); faturamento.enderecoCobrancaId = reader.GetString(6); faturamento.quantidadeItem = reader.GetString(7); faturamento.valorUnitarioItem = reader.GetString(8); faturamento.valorTotalFatura = reader.GetString(9); faturamento.valorBrutoItem = reader.GetString(10); faturamento.valorDescontoItem = reader.GetString(11); faturamento.valorTotalItem = reader.GetString(12); faturamento.valorLiquidoItem = reader.GetString(13); faturamento.valorCustoItem = reader.GetString(14); faturamento.quantidadeLitrosItem = reader.GetString(15); faturamento.numeroFatura = reader.GetString(16); faturamento.serieFatura = reader.GetString(17); faturamento.itemFatura = reader.GetString(18); faturamento.CFOP = reader.GetString(19); faturamento.naturezaOpercao = reader.GetString(20); if(reader.IsDBNull(21)) { faturamento.observacaoFatura = valid.ValidaString(); }else{ faturamento.observacaoFatura = reader.GetString(21); } faturamento.dataFatura = reader.GetString(22); faturamento.flagItemCancelado = (reader.GetString(23)); if (reader.IsDBNull(24)) { faturamento.dataItemCancelado = valid.ValidaString(); } else { faturamento.dataItemCancelado = reader.GetString(24); } if (reader.IsDBNull(25)) { faturamento.quantidadeItemCancelado = valid.ValidaString(); } else { faturamento.quantidadeItemCancelado = reader.GetString(25); } faturamento.valorFrete = reader.GetString(26); faturamento.valorIpi = reader.GetString(27); faturamento.valorPis = reader.GetString(28); faturamento.valorConfins = reader.GetString(29); faturamento.valorIcms = reader.GetString(30); faturamento.valorIcmsSt = reader.GetString(31); if (reader.IsDBNull(32)) { faturamento.valorSeguro = valid.ValidaString(); } else { faturamento.valorSeguro = (reader.GetValue(32).ToString()); } if (reader.IsDBNull(33)) { faturamento.valorDespesaExtra = valid.ValidaString(); } else { faturamento.valorDespesaExtra = reader.GetString(33); } if (reader.IsDBNull(34)) { faturamento.flagTipoEntrega = valid.ValidaString(); } else { faturamento.flagTipoEntrega = reader.GetString(34); } PostFaturamento(faturamento); string msg = "Foram inseridos: " + lFaturamento.Count().ToString() + " de " + countRegister + " registros"; processForm.writeMessage(msg); processForm.Enabled = false; processForm.Enabled = true; lFaturamento.Add(faturamento); } } con.Dispose(); } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } int countWrite = lFaturamento.Count(); //MessageBox.Show("Foram inseridos "+countWrite.ToString()+" registros", "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); processForm.Close(); }
private void Process_btn_Click(object sender, EventArgs e) { Com.Nidec.Mes.GlobalMasterMaintenance.ProcessForm processmasterform = new ProcessForm(); processmasterform.Show(); }
public void IntegraEstoque() { ProcessForm processForm = new ProcessForm("", layout); processForm.Show(); List<Estoque> lEstoque = new List<Estoque>(); IEnumerable<String> streamRead = File.ReadLines(System.Environment.CurrentDirectory.ToString() + "\\config.txt"); var connection = streamRead.First(); using (OleDbConnection con = new OleDbConnection(connection)) { try { con.Open(); using (OleDbCommand commandCount = new OleDbCommand("SELECT COUNT(*) FROM ESTOQUE ", con)) using (OleDbDataReader readerCount = commandCount.ExecuteReader()) { while (readerCount.Read()) { countRegister = readerCount.GetValue(0).ToString(); } } try { using (OleDbCommand command = new OleDbCommand("SELECT SKU_PRODUTO,ID_DISTRIBUIDOR,QUANTIDADE_ATUAL_ESTOQUE,QUANTIDADE_ULTIMA_COMPRA,QUANTIDADE_ULTIMA_VENDA,DATA_PRIMEIRA_COMPRA,DATA_ULTIMA_COMPRA,DATA_ULTIMA_VENDA,VALOR_CUSTO_UNITARIO_ESTOQUE,VALOR_CUSTO_TOTAL_ESTOQUE FROM ESTOQUE", con)) using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Estoque estoque = new Estoque(); Validator valid = new Validator(); estoque.produtoId = reader.GetString(0); estoque.distribuidorId = reader.GetString(1); estoque.quantidadeAtualEstoque = reader.GetString(2); estoque.quantidadeUltimaCompra = reader.GetString(3); estoque.quantidadeUltimaVenda = reader.GetString(4); if (reader.IsDBNull(5)) { estoque.dataPrimeiraCompra = valid.ValidaString(); } else { estoque.dataPrimeiraCompra = (reader.GetString(5)); } if (reader.IsDBNull(6)) { estoque.dataUltimaCompra = valid.ValidaString(); } else { estoque.dataUltimaCompra = (reader.GetString(6)); } if (reader.IsDBNull(7)) { estoque.dataUltimaVenda = valid.ValidaString(); } else { estoque.dataUltimaVenda = (reader.GetString(7)); } estoque.valorCustoUnitarioEstoque = reader.GetString(8); estoque.valorCustoTotalEstoque = reader.GetString(9); PostEstoque(estoque); string msg = "Foram inseridos: " + lEstoque.Count().ToString() + " de " + countRegister + " registros"; processForm.writeMessage(msg); processForm.Enabled = false; processForm.Enabled = true; lEstoque.Add(estoque); } } con.Dispose(); } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } int countWrite = lEstoque.Count(); //MessageBox.Show("Foram inseridos "+countWrite.ToString()+" registros", "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); processForm.Close(); } }
public void IntegraPedido() { ProcessForm processForm = new ProcessForm("", layout); processForm.Show(); List<Pedido> lPedido = new List<Pedido>(); IEnumerable<String> streamRead = File.ReadLines(System.Environment.CurrentDirectory.ToString() + "\\config.txt"); var connection = streamRead.First(); //int index = 0; using (OleDbConnection con = new OleDbConnection(connection)) { try { con.Open(); using (OleDbCommand commandCount = new OleDbCommand("SELECT COUNT(*) FROM PEDIDOS ", con)) using (OleDbDataReader readerCount = commandCount.ExecuteReader()) { while (readerCount.Read()) { countRegister = readerCount.GetValue(0).ToString(); } } try { using (OleDbCommand command = new OleDbCommand("SELECT SKU_PRODUTO,ID_CLIENTE,ID_DISTRIBUIDOR,ID_FV,ID_FORMA_PAGAMENTO,NUMERO_PEDIDO,DATA_PEDIDO,QUANTIDADE_ITEM_PEDIDO,VALOR_UNITARIO_PEDIDO,VALOR_TOTAL_ITEM_PEDIDO,CFOP_PEDIDO,NATUREZA_OPERACAO_NF,FLAG_PEDIDO_ITEM_CANCELADO,DATA_PEDIDO_ITEM_CANCELADO FROM PEDIDOS", con)) using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Pedido pedido = new Pedido(); pedido.produtoId = reader.GetString(0); pedido.clienteId= reader.GetString(1); pedido.distribuidorId = reader.GetString(2); pedido.forcaDeVendaId=reader.GetString(3); pedido.formaDePagamentoId = reader.GetString(4); pedido.numeroPedido = reader.GetString(5); pedido.data = reader.GetString(6); pedido.quantidadeItens = reader.GetString(7); pedido.valorUnitario = reader.GetString(8); pedido.valorTotalItens = reader.GetString(9); pedido.cfop = reader.GetString(10); pedido.naturezaOperacaoNF = reader.GetString(11); pedido.flagItemCancelado = reader.GetString(12); pedido.dataItemCancelado = reader.GetString(13); PostPedido(pedido); string msg = "Foram inseridos: " + lPedido.Count().ToString() +" de "+countRegister+ " registros"; processForm.writeMessage(msg); processForm.Enabled = false; processForm.Enabled = true; lPedido.Add(pedido); //index++; } } con.Dispose(); } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } int countWrite = lPedido.Count(); //MessageBox.Show("Foram inseridos "+countWrite.ToString()+" registros", "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); processForm.Close(); //return index; }
public int IntegraCliente() { ProcessForm processForm = new ProcessForm("", layout); processForm.Show(); List<Cliente> lCliente = new List<Cliente>(); IEnumerable<String> streamRead = File.ReadLines(System.Environment.CurrentDirectory.ToString()+"\\config.txt"); var connection = streamRead.First(); int index = 0; using (OleDbConnection con = new OleDbConnection(connection)) { try { con.Open(); using (OleDbCommand commandCount = new OleDbCommand("SELECT COUNT(*) FROM CLIENTES ", con)) using (OleDbDataReader readerCount = commandCount.ExecuteReader()) { while (readerCount.Read()) { countRegister = readerCount.GetValue(0).ToString(); } } try { using (OleDbCommand command = new OleDbCommand("SELECT ID_CLIENTE,ID_DISTRIBUIDOR,RAZAO_SOCIAL_CLIENTE,NOME_FANTASIA_CLIENTE,CNPJ_CPF_CLIENTE,COD_MUNICIPIO_IBGE_MATRIZ,RUA_END_MATRIZ_CLIENTE,NUMERO_END_MATRIZ_CLIENTE,COMPLEMENTO_END_MATRIZ_CLIENTE,CEP_END_MATRIZ_CLIENTE,BAIRRO_END_MATRIZ_CLIENTE,MUNICIPIO_END_MATRIZ_CLIENTE,UF_END_MATRIZ_CLIENTE,TEL_END_MATRIZ_CLIENTE,EMAIL_END_MATRIZ_CLIENTE,PESSOA_CONTATO,RAMO_NEGOCIO_CLIENTE,SUB_RAMO_NEGOCIO_CLIENTE,CURVA_ABC_CLIENTE,STATUS_FINANCEIRO_CLIENTE,DATA_CADASTRO_CLIENTE,DATA_DESATIVACAO_CLIENTE,FLAG_ATIVO_CLIENTE,GRUPO_ECONOMICO_CLIENTE FROM CLIENTES ", con)) using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Cliente cliente = new Cliente(); Validator valid = new Validator(); cliente.id = reader.GetString(0); cliente.distribuidorId = reader.GetString(1); cliente.razaoSocial = reader.GetString(2); cliente.nomeFantasia = reader.GetString(3); cliente.cnpjCpf = reader.GetString(4); if (reader.IsDBNull(5)) { cliente.codigoMunicipio = valid.ValidaString(); } else { cliente.codigoMunicipio = reader.GetString(5); } //cliente.codigoMunicipio = reader.GetString(5); if (reader.IsDBNull(6)) { cliente.enderecoLogradouro = valid.ValidaString(); } else { cliente.enderecoLogradouro = reader.GetString(6); } //cliente.enderecoLogradouro = reader.GetString(6); if (reader.IsDBNull(7)) { cliente.enderecoNumero = valid.ValidaString(); } else { cliente.enderecoNumero = reader.GetString(7); } //cliente.enderecoNumero = reader.GetString(7); if (reader.IsDBNull(8)) { cliente.enderecoComplemento = valid.ValidaString(); } else { cliente.enderecoComplemento = reader.GetString(8); } //cliente.enderecoComplemento = reader.GetString(8); if (reader.IsDBNull(9)) { cliente.enderecoCep = valid.ValidaString(); } else { cliente.enderecoCep = reader.GetString(9); } //cliente.enderecoCep = reader.GetString(9); if (reader.IsDBNull(10)) { cliente.enderecoBairro = valid.ValidaString(); } else { cliente.enderecoBairro = reader.GetString(10); } //cliente.enderecoBairro = reader.GetString(10); if (reader.IsDBNull(11)) { cliente.enderecoMunicipio = valid.ValidaString(); } else { cliente.enderecoMunicipio = reader.GetString(11); } //cliente.enderecoMunicipio = reader.GetString(11); if (reader.IsDBNull(12)) { cliente.enderecoEstado = valid.ValidaString(); } else { cliente.enderecoEstado = reader.GetString(12); } //cliente.enderecoEstado = reader.GetString(12); if (reader.IsDBNull(13)) { cliente.telefone = valid.ValidaString(); } else { cliente.telefone = reader.GetString(13); } //cliente.telefone = reader.GetString(13); if (reader.IsDBNull(14)) { cliente.email = valid.ValidaString(); } else { cliente.email = reader.GetString(14); } //cliente.email = reader.GetString(14); if (reader.IsDBNull(15)) { cliente.pessoaContato = valid.ValidaString(); } else { cliente.pessoaContato = reader.GetString(15); } //cliente.pessoaContato = reader.GetString(15); if (reader.IsDBNull(16)) { cliente.ramoNegocio = valid.ValidaString(); } else { cliente.ramoNegocio = reader.GetString(16); } //cliente.ramoNegocio = reader.GetString(16); if (reader.IsDBNull(17)) { cliente.subRamoNegocio = valid.ValidaString(); } else { cliente.subRamoNegocio = reader.GetString(17); } //cliente.subRamoNegocio = reader.GetString(17); if (reader.IsDBNull(18)) { cliente.curvaABC = valid.ValidaString(); } else { cliente.curvaABC = reader.GetString(18); } if (reader.IsDBNull(19)||reader.GetValue(19).ToString()=="") { cliente.statusFinanceiro = valid.ValidaString(); } else { cliente.statusFinanceiro = reader.GetString(19); } if ((reader.IsDBNull(20) || (reader.GetValue(20).ToString() == "") || (reader.GetValue(20) == null))) { cliente.dataCadastro = valid.ValidaString(); } else { cliente.dataCadastro = (reader.GetValue(20).ToString()); } if ((reader.IsDBNull(21)) || (reader.GetValue(21).ToString() == "") || (reader.GetValue(21)==null)) { cliente.dataDesativacao = valid.ValidaString(); } else { try { cliente.dataDesativacao = reader.GetString(20); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } //cliente.ativo = (reader.GetString(22)); if ((reader.IsDBNull(22) || (reader.GetValue(22).ToString() == "") || (reader.GetValue(22) == null))) { cliente.ativo = valid.ValidaString(); } else { cliente.ativo = reader.GetString(22); } if ((reader.IsDBNull(23) || (reader.GetValue(23).ToString() == "") || (reader.GetValue(23) == null))) { cliente.grupoEconomico = valid.ValidaString(); } else { cliente.grupoEconomico = reader.GetString(23); } PostCliente(cliente); string msg = "Foram inseridos: " + lCliente.Count().ToString() +" de "+countRegister+" registros"; processForm.writeMessage(msg); processForm.Enabled = false; processForm.Enabled = true; lCliente.Add(cliente); index++; } } con.Dispose(); //MessageBox.Show("Advetisament","Fim da execução de cliente",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); } catch (Exception ex) { logErro.EscreverLog(layout, ex.Message.ToString()+ex.ToString()); //MessageBox.Show(ex.Message.ToString(), "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { //MessageBox.Show(ex.Message.ToString(), "Falha ao abrir a conexao", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); logErro.EscreverLog(layout, ex.Message.ToString()); } int countWrite = lCliente.Count(); //MessageBox.Show("Foram inseridos " + countWrite.ToString() + " registros", "Advetisament", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); processForm.Close(); return index; } }