Esempio n. 1
0
        private void FrmGuiaCompraMaiz_Load(object sender, EventArgs e)
        {
            try
            {
                if (NumHojaLiquidacion != "")
                {
                    TxtNroHojaLiquidacion.Text = NumHojaLiquidacion;
                    Cursor = Cursors.WaitCursor;
                    Halley.Presentacion.CrystalReports.CrGuiaCompraMaiz rpt = new CrystalReports.CrGuiaCompraMaiz();

                    DataSet DS = new DataSet();

                    DS = new CL_GuiaCompraMaiz().GetFormatoHojaLiquidacion(NumHojaLiquidacion);

                    rpt.SetDataSource(DS);
                    //Establecemos los datos al reporte
                    this.CrvGuiaCompraMaiz.ReportSource = rpt;
                    //Refrescamos nuestro reporte
                    this.CrvGuiaCompraMaiz.RefreshReport();
                    Cursor = Cursors.Default;
                }
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private void TraerGuia(string NumHojaLiquidacion)
        {
            DataSet DS = new DataSet();

            #region Cabecera
            DS = new CL_GuiaCompraMaiz().GetFormatoHojaLiquidacion(NumHojaLiquidacion);
            if (DS.Tables["Cabecera"].Rows.Count > 0)
            {
                TxtReadOnly(false);
                TxtEstado.Text            = DS.Tables["Cabecera"].Rows[0]["NomEstado"].ToString();
                TxNumHojaLiquidacion.Text = DS.Tables["Cabecera"].Rows[0]["NumHojaLiquidacion"].ToString();
                TxtAudCrea.Text           = DS.Tables["Cabecera"].Rows[0]["AudCrea"].ToString();
                TxtProductoID.Text        = DS.Tables["Cabecera"].Rows[0]["ProductoID"].ToString();
                TxtNomProducto.Text       = DS.Tables["Cabecera"].Rows[0]["Alias"].ToString();
                TxtSacos.Text             = DS.Tables["Cabecera"].Rows[0]["Sacos"].ToString();
                TxtNombreProveedor.Text   = DS.Tables["Cabecera"].Rows[0]["NombreProveedor"].ToString();
                TxtTotalPeso.Text         = DS.Tables["Cabecera"].Rows[0]["TotalPeso"].ToString();
                TxtTotalSaco.Text         = DS.Tables["Cabecera"].Rows[0]["TotalSaco"].ToString();
                TxtProcedencia.Text       = DS.Tables["Cabecera"].Rows[0]["Procedencia"].ToString();
                TxtDNI.Text            = DS.Tables["Cabecera"].Rows[0]["DNI"].ToString();
                TxtPrecioUnitario.Text = DS.Tables["Cabecera"].Rows[0]["PrecioUnitario"].ToString();
                decimal TotalPagar = 0;
                TotalPagar         = Convert.ToDecimal(TxtTotalPeso.Text) * Convert.ToDecimal(TxtPrecioUnitario.Text);
                TxtTotalPagar.Text = decimal.Round(TotalPagar, 3).ToString();
                TxtComentario.Text = DS.Tables["Cabecera"].Rows[0]["Comentario"].ToString();
                TxtSede.Text       = DS.Tables["Cabecera"].Rows[0]["NomSede"].ToString();
                TxtDireccion.Text  = DS.Tables["Cabecera"].Rows[0]["Direccion"].ToString();
                EstadoID           = Convert.ToInt16(DS.Tables["Cabecera"].Rows[0]["EstadoID"]);
                TxtPagado.Text     = DS.Tables["Cabecera"].Rows[0]["Pagado"].ToString();

                GbLiquidacion.Enabled           = true;
                TxtOperacionCajaBancoID.Enabled = true;
                TxtDescripcionOperacion.Enabled = true;
                TxtOperacionCajaBancoID.Text    = DS.Tables["OperacionCajaBanco"].Rows[0]["OperacionCajaBancoID"].ToString();
                TxtDescripcionOperacion.Text    = DS.Tables["OperacionCajaBanco"].Rows[0]["DescripcionOperacion"].ToString();
                TxtOperacionCajaBancoID.Enabled = false;
                TxtDescripcionOperacion.Enabled = false;
                TxtMontoAPagar.Text             = decimal.Round(Convert.ToDecimal(TxtTotalPeso.Text) * Convert.ToDecimal(TxtPrecioUnitario.Text) - Convert.ToDecimal(TxtPagado.Text), 3).ToString();

                //validar el panel "liquidar"
                if (EstadoID == 12)
                {
                    GbLiquidacion.Enabled = false;
                }
                else
                {
                    GbLiquidacion.Enabled = true;
                }

                TxtReadOnly(true);
                #endregion

                /*
                 * DataTable Usp_GetDetalleGuiaCompraMaiz = new DataTable();
                 * Usp_GetDetalleGuiaCompraMaiz = new CL_GuiaCompraMaiz().GetDetalleGuiaCompraMaiz(NumHojaLiquidacion);
                 *
                 * TdgDetalleGuiaMaiz.SetDataBinding(Usp_GetDetalleGuiaCompraMaiz, "", true);*/
            }
        }
Esempio n. 3
0
 private void BtnBuscar_Click(object sender, EventArgs e)
 {
     TxtReadOnly(false);
     Limpiar();
     TxtReadOnly(true);
     ErrProvider.Clear();
     if (TxtBuscar.Text != "")
     {
         //obtener las guias de liquidacion
         if (RbCodigo.Checked == true)
         {
             NumHojaLiquidacion = TxtBuscar.Text;
             TraerGuia(NumHojaLiquidacion);
         }
         else if (RbDNI.Checked == true)
         {
             //devuelve una lista de codigos amarrados a un DNI
             DataTable Dt = new DataTable();
             Dt = new CL_GuiaCompraMaiz().GetGuiaCompraMaizDNI(TxtBuscar.Text);
             LstCodigos.DataSource    = Dt;
             LstCodigos.DisplayMember = "AudCrea";
             LstCodigos.ValueMember   = "NumHojaLiquidacion";
             if (Dt.Rows.Count == 1)
             {
                 NumHojaLiquidacion = Dt.Rows[0]["NumHojaLiquidacion"].ToString();
                 TraerGuia(NumHojaLiquidacion);
             }
         }
     }
     else
     {
         if (RbCodigo.Checked == true)
         {
             ErrProvider.SetError(TxtBuscar, "Debe ingresar un código de liquidación a buscar.");
         }
         else if (RbDNI.Checked == true)
         {
             ErrProvider.SetError(TxtBuscar, "Debe ingresar un DNI a Buscar");
         }
     }
 }
Esempio n. 4
0
        private void CrearCompraMaiz()
        {
            try
            {
                //calcular peso
                decimal PesoTotal = 0;
                decimal DescPorc  = 0;
                decimal DescSac   = 0;

                if (TxtPorcDesc.Text != "" & TxtPorcDesc.Text != "0")
                {
                    DescPorc = Convert.ToDecimal(TxtPorcDesc.Text) / 100 * Convert.ToDecimal(TxtTotalKilos.Text);
                }
                if (Convert.ToInt16(CboSacos.SelectedValue) == 2)
                {
                    DescSac = Convert.ToInt16(TxtTotalSacos.Text);
                }

                PesoTotal = Convert.ToDecimal(TxtTotalKilos.Text) - DescPorc - DescSac;

                //insertar la guia y que retorne el nro de guia
                CL_GuiaCompraMaiz ObjCL_GuiaCompraMaiz = new CL_GuiaCompraMaiz();
                E_GuiaCompraMaiz  ObjE_GuiaCompraMaiz  = new E_GuiaCompraMaiz();
                ObjE_GuiaCompraMaiz.IDProveedor     = Convert.ToInt16(CboProveedor.SelectedValue);
                ObjE_GuiaCompraMaiz.NombreProveedor = CboProveedor.SelectedText;
                ObjE_GuiaCompraMaiz.Procedencia     = TxtProcedencia.Text;
                ObjE_GuiaCompraMaiz.Sacos           = CboSacos.Text;
                ObjE_GuiaCompraMaiz.DNI             = TxtDocumento.Text;
                ObjE_GuiaCompraMaiz.PrecioUnitario  = Convert.ToDecimal(TxtPrecioUnitario.Text.ToString());
                ObjE_GuiaCompraMaiz.ProductoID      = CboProductoPeso.SelectedValue.ToString();
                ObjE_GuiaCompraMaiz.TotalPeso       = PesoTotal;
                ObjE_GuiaCompraMaiz.TotalSaco       = Convert.ToInt16(TxtTotalSacos.Text);
                ObjE_GuiaCompraMaiz.Comentario      = TxtComentario.Text;
                ObjE_GuiaCompraMaiz.UsuarioID       = AppSettings.UserID;
                ObjE_GuiaCompraMaiz.Pagado          = 0; //monto pagado


                //insertar detalles de la guia
                DataTable DtPesos = new DataTable();//tabla apra almacenar los pesos
                DtPesos.TableName = "HojaLiquidacion";
                DtPesos.Columns.Add("Kilo", typeof(decimal));
                DtPesos.Columns.Add("Saco", typeof(int));

                #region Llenar tabla pesos
                for (int x = 0; x < LstKilo1.Items.Count; x++)
                {
                    DataRow Rw1 = DtPesos.NewRow();
                    Rw1["Kilo"] = Convert.ToDecimal(LstKilo1.Items[x]);
                    Rw1["Saco"] = Convert.ToInt16(LstSaco1.Items[x]);
                    DtPesos.Rows.Add(Rw1);
                }
                for (int x = 0; x < LstKilo2.Items.Count; x++)
                {
                    DataRow Rw1 = DtPesos.NewRow();
                    Rw1["Kilo"] = Convert.ToDecimal(LstKilo2.Items[x]);
                    Rw1["Saco"] = Convert.ToInt16(LstSaco2.Items[x]);
                    DtPesos.Rows.Add(Rw1);
                }
                for (int x = 0; x < LstKilo3.Items.Count; x++)
                {
                    DataRow Rw1 = DtPesos.NewRow();
                    Rw1["Kilo"] = Convert.ToDecimal(LstKilo3.Items[x]);
                    Rw1["Saco"] = Convert.ToInt16(LstSaco3.Items[x]);
                    DtPesos.Rows.Add(Rw1);
                }
                for (int x = 0; x < LstKilo4.Items.Count; x++)
                {
                    DataRow Rw1 = DtPesos.NewRow();
                    Rw1["Kilo"] = Convert.ToDecimal(LstKilo4.Items[x]);
                    Rw1["Saco"] = Convert.ToInt16(LstSaco4.Items[x]);
                    DtPesos.Rows.Add(Rw1);
                }
                for (int x = 0; x < LstKilo5.Items.Count; x++)
                {
                    DataRow Rw1 = DtPesos.NewRow();
                    Rw1["Kilo"] = Convert.ToDecimal(LstKilo5.Items[x]);
                    Rw1["Saco"] = Convert.ToInt16(LstSaco5.Items[x]);
                    DtPesos.Rows.Add(Rw1);
                }

                //hacer descuento según la opcion de los sacos
                if (Convert.ToInt16(CboSacos.SelectedValue) == 2)
                {
                    DataRow Rw1 = DtPesos.NewRow();
                    Rw1["Kilo"] = Convert.ToDecimal(TxtTotalSacos.Text) * -1;
                    Rw1["Saco"] = 0;
                    DtPesos.Rows.Add(Rw1);
                }

                //hacer descuento según la calidad del maiz
                if (TxtPorcDesc.Text != "" && TxtPorcDesc.Text != "0")
                {
                    DataRow Rw1 = DtPesos.NewRow();
                    Rw1["Kilo"] = Convert.ToDecimal(TxtTotalKilos.Text) * Convert.ToDecimal(TxtPorcDesc.Text) / 100 * -1;
                    Rw1["Saco"] = 0;
                    DtPesos.Rows.Add(Rw1);
                }
                #endregion

                string xml = new BaseFunctions().GetXML(DtPesos).Replace("NewDataSet", "DocumentElement");
                NumHojaLiquidacion = ObjCL_GuiaCompraMaiz.InsertHojaLiquidacion(ObjE_GuiaCompraMaiz, AppSettings.EmpresaID, AppSettings.SedeID, xml, CboAlmacen.SelectedValue.ToString(), null, "02");
                MessageBox.Show("Se grabo correctamente la compra", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ".\t\nmetodo CrearCompraMaiz()", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }