Example #1
0
        public bool actualizarRegistro(eBONIFICACION oeBONIFICACION)
        {
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString()))
            {
                string     sp  = "pa_crud_BONIFICACION_actualizarRegistro";
                SqlCommand cmd = new SqlCommand(sp, cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                cnn.Open();

                cmd.Parameters.Add(new SqlParameter("@CAN_CODIGO", oeBONIFICACION.CAN_codigo));                                               //variable tipo:string
                cmd.Parameters.Add(new SqlParameter("@PRO_CODIGO", oeBONIFICACION.PRO_codigo));                                               //variable tipo:string
                cmd.Parameters.Add(new SqlParameter("@BON_IS_ESPECIAL", oeBONIFICACION.BON_is_especial));                                     //variable tipo:string
                cmd.Parameters.Add(new SqlParameter("@BON_CANTIDAD_REQ", oeBONIFICACION.BON_cantidad_req));                                   //variable tipo:int
                cmd.Parameters.Add(new SqlParameter("@BON_CANTIDAD_REQ_SUBMULTIPLO", oeBONIFICACION.BON_cantidad_req_submultiplo));           //variable tipo:int
                cmd.Parameters.Add(new SqlParameter("@BON_CANTIDAD_BONI", oeBONIFICACION.BON_cantidad_boni));                                 //variable tipo:int
                cmd.Parameters.Add(new SqlParameter("@BON_CANTIDAD_BONI_SUBMULTIPLO", oeBONIFICACION.BON_cantidad_boni_submultiplo));         //variable tipo:int
                cmd.Parameters.Add(new SqlParameter("@BON_ESP_CANTIDAD_BONI", oeBONIFICACION.BON_esp_cantidad_boni));                         //variable tipo:int
                cmd.Parameters.Add(new SqlParameter("@BON_ESP_CANTIDAD_BONI_SUBMULTIPLO", oeBONIFICACION.BON_esp_cantidad_boni_submultiplo)); //variable tipo:int
                cmd.Parameters.Add(new SqlParameter("@BON_PRODUCTO", oeBONIFICACION.BON_producto));                                           //variable tipo:string
                cmd.Parameters.Add(new SqlParameter("@BON_FECHA_VENCIMIENTO", (object)oeBONIFICACION.BON_fecha_vencimiento ?? DBNull.Value)); //variable tipo:DateTime

                return(cmd.ExecuteNonQuery() > 0);
            }
        }
Example #2
0
        public void eliminarTabla(eBONIFICACION oeBONIFICACION)
        {
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString()))
            {
                string     sp  = "[pa_op_BONIFICACION_EliminarTabla]";
                SqlCommand cmd = new SqlCommand(sp, cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                cnn.Open();
                cmd.Parameters.Add(new SqlParameter("@CAN_CODIGO", oeBONIFICACION.CAN_codigo));
                cmd.ExecuteNonQuery();
            }
        }
Example #3
0
        public bool eliminarRegistro(eBONIFICACION oeBONIFICACION)
        {
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString()))
            {
                string     sp  = "pa_crud_BONIFICACION_eliminarRegistro";
                SqlCommand cmd = new SqlCommand(sp, cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                cnn.Open();

                cmd.Parameters.Add(new SqlParameter("@CAN_CODIGO", oeBONIFICACION.CAN_codigo));
                cmd.Parameters.Add(new SqlParameter("@PRO_CODIGO", oeBONIFICACION.PRO_codigo));

                return(cmd.ExecuteNonQuery() > 0);
            }
        }
Example #4
0
        public DataTable obtenerRegistro(eBONIFICACION oeBONIFICACION)
        {
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString()))
            {
                string     sp  = "pa_crud_BONIFICACION_obtenerRegistro";
                SqlCommand cmd = new SqlCommand(sp, cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter dad = new SqlDataAdapter(cmd);
                dad.SelectCommand.Parameters.Add(new SqlParameter("@CAN_CODIGO", oeBONIFICACION.CAN_codigo));
                dad.SelectCommand.Parameters.Add(new SqlParameter("@PRO_CODIGO", oeBONIFICACION.PRO_codigo));

                DataTable dt = new DataTable();
                dad.Fill(dt);

                return(dt);
            }
        }
        public override void Guardar()
        {
            eBONIFICACION oeBONIFICACION = new eBONIFICACION();

            int contadorInsertadosCorrectos   = 0;
            int contadorInsertadosIncorrectos = 0;

            bool bandera = true;

            foreach (DataGridViewRow row in this.dgvListado.Rows)
            {
                if (!row.IsNewRow)
                {
                    if ((row.Cells["Cantidad_1"].Value == null ||
                         row.Cells["Cantidad_sub_1"].Value == null ||
                         row.Cells["Cantidad_2"].Value == null ||
                         row.Cells["Cantidad_sub_2"].Value == null ||
                         row.Cells["Cantidad_esp_2"].Value == null ||
                         row.Cells["Cantidad_esp_sub_2"].Value == null ||
                         row.Cells["PRO_codigo_1"].Value == null ||
                         row.Cells["PRO_codigo_2"].Value == null))
                    {
                        bandera = false;
                    }
                    else
                    {
                        if
                        ((Convert.ToInt16(row.Cells["Cantidad_1"].Value.ToString()) <= 0 &&
                          Convert.ToInt16(row.Cells["Cantidad_sub_1"].Value.ToString()) <= 0)
                         ||
                         (Convert.ToInt16(row.Cells["Cantidad_2"].Value.ToString()) <= 0 &&
                          Convert.ToInt16(row.Cells["Cantidad_sub_2"].Value.ToString()) <= 0)
                         ||
                         (Convert.ToInt16(row.Cells["Cantidad_esp_2"].Value.ToString()) <= 0 &&
                          Convert.ToInt16(row.Cells["Cantidad_esp_sub_2"].Value.ToString()) <= 0))
                        {
                            bandera = false;
                        }
                    }
                }
            }

            if (bandera)
            {
                string   canal = this.cmbCanal.SelectedValue.ToString();
                DateTime u;
                oeBONIFICACION.CAN_codigo = canal;
                balBONIFICACION.eliminarTabla(oeBONIFICACION);

                foreach (DataGridViewRow row in this.dgvListado.Rows)
                {
                    if (!row.IsNewRow)
                    {
                        string   BON_is_especial       = row.Cells["BON_is_especial"].Value != null ? row.Cells["BON_is_especial"].Value.ToString() : "N";
                        string   PRO_codigo_1          = row.Cells["PRO_codigo_1"].Value.ToString();
                        string   PRO_codigo_2          = row.Cells["PRO_codigo_2"].Value.ToString();
                        int      Cantidad_1            = Convert.ToInt16(row.Cells["Cantidad_1"].Value.ToString());
                        int      Cantidad_sub_1        = Convert.ToInt16(row.Cells["Cantidad_sub_1"].Value.ToString());
                        int      Cantidad_2            = Convert.ToInt16(row.Cells["Cantidad_2"].Value.ToString());
                        int      Cantidad_sub_2        = Convert.ToInt16(row.Cells["Cantidad_sub_2"].Value.ToString());
                        int      Cantidad_esp_2        = Convert.ToInt16(row.Cells["Cantidad_esp_2"].Value.ToString());
                        int      Cantidad_esp_sub_2    = Convert.ToInt16(row.Cells["Cantidad_esp_sub_2"].Value.ToString());
                        DateTime?DSC_fecha_vencimiento = (row.Cells["BON_fecha_vencimiento"].Value != null) ? DateTime.TryParse(row.Cells["BON_fecha_vencimiento"].Value.ToString(), out u) ? Convert.ToDateTime(row.Cells["BON_fecha_vencimiento"].Value.ToString()) : (DateTime?)null : null;

                        oeBONIFICACION.PRO_codigo                        = PRO_codigo_1;
                        oeBONIFICACION.BON_is_especial                   = BON_is_especial;
                        oeBONIFICACION.BON_cantidad_req                  = Cantidad_1;
                        oeBONIFICACION.BON_cantidad_req_submultiplo      = Cantidad_sub_1;
                        oeBONIFICACION.BON_producto                      = PRO_codigo_2;
                        oeBONIFICACION.BON_cantidad_boni                 = Cantidad_2;
                        oeBONIFICACION.BON_cantidad_boni_submultiplo     = Cantidad_sub_2;
                        oeBONIFICACION.BON_esp_cantidad_boni             = Cantidad_esp_2;
                        oeBONIFICACION.BON_esp_cantidad_boni_submultiplo = Cantidad_esp_sub_2;
                        oeBONIFICACION.BON_fecha_vencimiento             = DSC_fecha_vencimiento;

                        if (balBONIFICACION.actualizarTabla(oeBONIFICACION))
                        {
                            contadorInsertadosCorrectos++;
                        }
                        else
                        {
                            contadorInsertadosIncorrectos++;
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Por favor ingrese todos los campos requeridos en la fila y valide que las cantidades sean mayores a cero.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            mensaje("guardar", contadorInsertadosCorrectos, contadorInsertadosIncorrectos);
            //MessageBox.Show("Resultados de la operaciĆ³n\r\n\r\nFilas insertadas: " + contadorInsertadosCorrectos + "\r\nErrores: " + contadorInsertadosIncorrectos, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }