protected void btnGuardarReport_Click(object sender, EventArgs e) { try { if (ddlCanal.Text == "0" || ddlCampana.Text == "0" || ddlNodeComercial.Text == "0" || ddlPuntoVenta.Text == "0" || ddlCategoria.Text == "0") { return; } Lucky.Business.Common.Application.OPE_Reporte_SOD oOPE_Reporte_SOD = new Lucky.Business.Common.Application.OPE_Reporte_SOD(); DataTable dt = null; DataTable dtl = null; Conexion Ocoon = new Conexion(); Conexion con = new Conexion(2); dt = Ocoon.ejecutarDataTable("UP_WEB_SEARCH_USER", "", Convert.ToInt32(this.Session["personid"].ToString())); string idperfil = dt.Rows[0]["Perfil_id"].ToString(); dtl = con.ejecutarDataTable("STP_JVM_LISTAR_CANALES", ddlCanal.SelectedValue); string tipocanal = dtl.Rows[0]["CAN_TIPO"].ToString(); Lucky.Entity.Common.Application.EOPE_Reporte_SOD oEOPE_Reporte_SOD = oOPE_Reporte_SOD.RegistrarReporteSOD(Convert.ToInt32(this.Session["personid"].ToString()), idperfil, ddlCampana.SelectedValue, this.Session["companyid"].ToString(), ddlPuntoVenta.SelectedValue, ddlCategoria.SelectedValue, DateTime.Now.ToShortDateString(), "0", "0", "0", txtObservacion.Text); oOPE_Reporte_SOD.RegistrarReporteStock_Detalle(Convert.ToInt32(oEOPE_Reporte_SOD.ID_REG_SOD), ddlMarca.SelectedValue, txtPrimaria.Text, txtSecundaria.Text, ""); LimpiarControles(); lblmensaje.Visible = true; lblmensaje.Text = "Fue registrado con exito el reporte de SOD"; lblmensaje.ForeColor = System.Drawing.Color.Blue; } catch (Exception ex) { string error = ""; string mensaje = ""; error = Convert.ToString(ex.Message); // mensaje = ConfigurationManager.AppSettings["ErrorConection"]; if (error == mensaje) { Lucky.CFG.Exceptions.Exceptions exs = new Lucky.CFG.Exceptions.Exceptions(ex); string errMessage = ""; errMessage = mensaje; errMessage = new Lucky.CFG.Util.Functions().preparaMsgError(ex.Message); this.Response.Redirect("../../../err_mensaje.aspx?msg=" + errMessage, true); } else { this.Session.Abandon(); Response.Redirect("~/err_mensaje_seccion.aspx", true); } } }
protected void btnCargaMasiva_Click(object sender, EventArgs e) { if ((FileUpCMasivo.PostedFile != null) && (FileUpCMasivo.PostedFile.ContentLength > 0)) { string fn = System.IO.Path.GetFileName(FileUpCMasivo.PostedFile.FileName); string SaveLocation = Server.MapPath("masivo") + "\\" + fn; if (SaveLocation != string.Empty) { if (FileUpCMasivo.FileName.ToLower().EndsWith(".xls")) { // string Destino = Server.MapPath(null) + "\\PDV_Planning\\" + Path.GetFileName(FileUpPDV.PostedFile.FileName); OleDbConnection oConn1 = new OleDbConnection(); OleDbCommand oCmd = new OleDbCommand(); OleDbDataAdapter oDa = new OleDbDataAdapter(); DataSet oDs = new DataSet(); DataTable dt = new DataTable(); FileUpCMasivo.PostedFile.SaveAs(SaveLocation); // oConn1.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + SaveLocation + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\""; oConn1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + SaveLocation + ";Extended Properties=\"Excel 8.0; HDR=YES;\""; oConn1.Open(); oCmd.CommandText = ConfigurationManager.AppSettings["CargaMasiva_Ope_SOD"]; oCmd.Connection = oConn1; oDa.SelectCommand = oCmd; try { oDa.Fill(oDs); dt = oDs.Tables[0]; int numcol = 6; //determina el número de columnas para el datatable if (dt.Columns.Count == numcol) { dt.Columns[0].ColumnName = "cod_ptoVenta"; dt.Columns[1].ColumnName = "cod_Categoria"; dt.Columns[2].ColumnName = "Observacion"; dt.Columns[3].ColumnName = "cod_Marca"; dt.Columns[4].ColumnName = "Exhib_Primaria"; dt.Columns[5].ColumnName = "Exhib_Secudaria"; string idPlanning = ddlCampañaCargaMasiva.SelectedValue; string companyid = this.Session["companyid"].ToString(); string usuario = this.Session["sUser"].ToString().Trim(); // cargarCategoria(idPlanning); //llenarPuntoVenta1(idPlanning, 0); OPE_Reporte_SOD oOPE_Reporte_SOD = new OPE_Reporte_SOD(); for (int i = 0; i <= dt.Rows.Count - 1; i++) { string cod_ptoVenta = dt.Rows[i]["cod_ptoVenta"].ToString(); string cod_Categoria = dt.Rows[i]["cod_Categoria"].ToString(); string Observacion = dt.Rows[i]["Observacion"].ToString(); string cod_Marca = dt.Rows[i]["cod_Marca"].ToString(); string Exhib_Primaria = dt.Rows[i]["Exhib_Primaria"].ToString(); string Exhib_Secudaria = dt.Rows[i]["Exhib_Secudaria"].ToString(); // llenarMarca1(id_Categoria); // llenaProducto(Convert.ToInt32(companyid), id_Categoria, Convert.ToInt32(id_Marca)); //ddlPuntoVenta.Items.FindByValue(id_ClientPDV).Selected = true; //ddlCategoria.Items.FindByValue(id_Categoria).Selected = true; // ddlMarca.Items.FindByValue(id_Marca).Selected = true; // Lucky.Business.Common.Application.OPE_Reporte_SOD oOPE_Reporte_SOD = new Lucky.Business.Common.Application.OPE_Reporte_SOD(); //DataTable dt = null; //DataTable dtl = null; Conexion Ocoon = new Conexion(); Conexion con = new Conexion(2); dt = Ocoon.ejecutarDataTable("UP_WEB_SEARCH_USER", "", Convert.ToInt32(this.Session["personid"].ToString())); string idperfil = dt.Rows[0]["Perfil_id"].ToString(); // dtl = con.ejecutarDataTable("STP_JVM_LISTAR_CANALES", ddlCanal.SelectedValue); // string tipocanal = dtl.Rows[0]["CAN_TIPO"].ToString(); Lucky.Entity.Common.Application.EOPE_Reporte_SOD oEOPE_Reporte_SOD = oOPE_Reporte_SOD.RegistrarReporteSOD(Convert.ToInt32(this.Session["personid"].ToString()), idperfil, ddlCampañaCargaMasiva.SelectedValue, this.Session["companyid"].ToString(), cod_ptoVenta, cod_Categoria, DateTime.Now.ToShortDateString(), "0", "0", "0", Observacion); oOPE_Reporte_SOD.RegistrarReporteStock_Detalle(Convert.ToInt32(oEOPE_Reporte_SOD.ID_REG_SOD), cod_Marca, Exhib_Primaria, Exhib_Secudaria, ""); } LimpiarControles(); lblmensaje.Visible = true; lblmensaje.Text = "Fue registrado con exito el reporte de SOD"; lblmensaje.ForeColor = System.Drawing.Color.Blue; //realiza las validaciones y carga los productos a planning. //DataSet dsCargar = oCoon.ejecutarDataSet("UP_WEBXPLORA_PLA_CARGAMASIVA_PRECIO_PLANNING_TMP", //idPlanning, //Convert.ToInt32(id_ReportsPlanning), //usuario, DateTime.Now, //usuario, DateTime.Now); } //} } catch { lblmensaje.Text = "Por favor revise la consistencia de la información"; } } } } }