Пример #1
0
        private void BtnNuevo_Click(object sender, EventArgs e)
        {
            TcOpciones_SelectedIndexChanged(null, null);
            DataTable dt1 = new DataTable();
            DataTable dt2 = new DataTable();

            TcProduccion.SelectedIndex = 0;
            TdgMicro.SetDataBinding(dt1, "", true);
            TcProduccion.SelectedIndex = 1;
            TdgMacro.SetDataBinding(dt2, "", true);
        }
Пример #2
0
        private void BtnMostrarPlan_Click(object sender, EventArgs e)
        {
            try
            {
                bool HayCero = false;
                foreach (DataRow Drv in DtProductosBatch.Rows)
                {
                    decimal val;
                    val = Convert.ToDecimal(Drv["Batch"]);
                    if (val == 0)
                    {
                        HayCero = true;
                    }
                }

                if (TcOpciones.SelectedIndex == 0)
                {
                    #region Actual
                    if (DtProductosBatch.Rows.Count > 0 && HayCero == false)
                    {
                        //traer todos las formulas del batch
                        Ds = new DataSet();

                        string empresa = "", sede = "001PU";
                        if (CboEmpresa.SelectedIndex == 0)
                        {
                            empresa = "IH";
                        }
                        else
                        {
                            empresa = "GH";
                        }


                        Ds = ObjCL_Produccion.GetMateriasPrimas(DtProductosBatch, empresa, sede);

                        #region Microinsumos
                        TcProduccion.SelectedIndex = 0;
                        TdgMicro.SetDataBinding(Ds.Tables["DtPlanProduccionMII"], "", false);

                        this.TdgMicro.Columns["Batch"].Caption = "Batch";
                        this.TdgMicro.Splits[0].DisplayColumns["Batch"].Style.Locked = true;
                        this.TdgMicro.Splits[0].DisplayColumns["Batch"].Visible      = true;
                        this.TdgMicro.Splits[0].DisplayColumns["Batch"].Width        = 100;
                        this.TdgMicro.Splits[0].DisplayColumns["Batch"].Merge        = ColumnMergeEnum.Free;

                        this.TdgMicro.Columns["ProductoID"].Caption = "ProductoID";
                        this.TdgMicro.Splits[0].DisplayColumns["ProductoID"].Style.Locked = true;
                        this.TdgMicro.Splits[0].DisplayColumns["ProductoID"].Visible      = false;
                        this.TdgMicro.Splits[0].DisplayColumns["ProductoID"].Width        = 280;
                        this.TdgMicro.Splits[0].DisplayColumns["ProductoID"].Merge        = ColumnMergeEnum.Free;

                        this.TdgMicro.Columns["NomProducto"].Caption = "Producto Terminado";
                        this.TdgMicro.Splits[0].DisplayColumns["NomProducto"].Style.Locked = true;
                        this.TdgMicro.Splits[0].DisplayColumns["NomProducto"].Visible      = true;
                        this.TdgMicro.Splits[0].DisplayColumns["NomProducto"].Width        = 250;
                        this.TdgMicro.Splits[0].DisplayColumns["NomProducto"].Merge        = ColumnMergeEnum.Free;

                        for (int x = 3; x < Ds.Tables["DtPlanProduccionMII"].Columns.Count; x++)
                        {
                            this.TdgMicro.Columns[Ds.Tables["DtPlanProduccionMII"].Columns[x].ColumnName].Caption      = Ds.Tables["DtPlanProduccionMII"].Columns[x].ColumnName;
                            this.TdgMicro.Columns[Ds.Tables["DtPlanProduccionMII"].Columns[x].ColumnName].NumberFormat = "FormatText Event";
                            this.TdgMicro.Splits[0].DisplayColumns[Ds.Tables["DtPlanProduccionMII"].Columns[x].ColumnName].Style.Locked = true;
                            this.TdgMicro.Splits[0].DisplayColumns[Ds.Tables["DtPlanProduccionMII"].Columns[x].ColumnName].Visible      = true;
                            this.TdgMicro.Splits[0].DisplayColumns[Ds.Tables["DtPlanProduccionMII"].Columns[x].ColumnName].Width        = 230;
                            //this.TdgMicro.Splits[0].DisplayColumns["NomProducto"].Merge = ColumnMergeEnum.Free;
                        }
                        TdgMicro.EmptyRows = true;
                        #endregion

                        #region Macroinsumos
                        TcProduccion.SelectedIndex = 1;
                        TdgMacro.SetDataBinding(Ds.Tables["DtPlanProduccionMAI"], "", false);

                        this.TdgMacro.Columns["Batch"].Caption = "Batch";
                        this.TdgMacro.Splits[0].DisplayColumns["Batch"].Style.Locked = true;
                        this.TdgMacro.Splits[0].DisplayColumns["Batch"].Visible      = true;
                        this.TdgMacro.Splits[0].DisplayColumns["Batch"].Width        = 100;
                        this.TdgMacro.Splits[0].DisplayColumns["Batch"].Merge        = ColumnMergeEnum.Free;

                        this.TdgMacro.Columns["ProductoID"].Caption = "ProductoID";
                        this.TdgMacro.Splits[0].DisplayColumns["ProductoID"].Style.Locked = true;
                        this.TdgMacro.Splits[0].DisplayColumns["ProductoID"].Visible      = false;
                        this.TdgMacro.Splits[0].DisplayColumns["ProductoID"].Width        = 280;
                        this.TdgMacro.Splits[0].DisplayColumns["ProductoID"].Merge        = ColumnMergeEnum.Free;

                        this.TdgMacro.Columns["NomProducto"].Caption = "Producto Terminado";
                        this.TdgMacro.Splits[0].DisplayColumns["NomProducto"].Style.Locked = true;
                        this.TdgMacro.Splits[0].DisplayColumns["NomProducto"].Visible      = true;
                        this.TdgMacro.Splits[0].DisplayColumns["NomProducto"].Width        = 250;
                        this.TdgMacro.Splits[0].DisplayColumns["NomProducto"].Merge        = ColumnMergeEnum.Free;

                        for (int x = 3; x < Ds.Tables["DtPlanProduccionMAI"].Columns.Count; x++)
                        {
                            this.TdgMacro.Columns[Ds.Tables["DtPlanProduccionMAI"].Columns[x].ColumnName].Caption      = Ds.Tables["DtPlanProduccionMAI"].Columns[x].ColumnName;
                            this.TdgMacro.Columns[Ds.Tables["DtPlanProduccionMAI"].Columns[x].ColumnName].NumberFormat = "FormatText Event";
                            this.TdgMacro.Splits[0].DisplayColumns[Ds.Tables["DtPlanProduccionMAI"].Columns[x].ColumnName].Style.Locked = true;
                            this.TdgMacro.Splits[0].DisplayColumns[Ds.Tables["DtPlanProduccionMAI"].Columns[x].ColumnName].Visible      = true;
                            this.TdgMacro.Splits[0].DisplayColumns[Ds.Tables["DtPlanProduccionMAI"].Columns[x].ColumnName].Width        = 230;
                            //this.TdgMacro.Splits[0].DisplayColumns["NomProducto"].Merge = ColumnMergeEnum.Free;
                        }
                        TdgMacro.EmptyRows = true;
                        #endregion
                    }
                    else
                    {
                        MessageBox.Show("No se ha agregado todavia ningun producto terminado o un batch es iguala '0'.", "Error en Plan de produccion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        TcProduccion.SelectedIndex = 0;
                        DataTable dt1 = new DataTable();
                        DataTable dt2 = new DataTable();

                        TcProduccion.SelectedIndex = 0;
                        TdgMicro.SetDataBinding(dt1, "", true);
                        TcProduccion.SelectedIndex = 1;
                        TdgMacro.SetDataBinding(dt2, "", true);
                    }
                    #endregion
                }
                else if (TcOpciones.SelectedIndex == 1)
                {
                    #region Historico
                    if (LstHistorico.SelectedIndex != -1 & HayCero == false & DtProductosBatch.Rows.Count > 0)
                    {
                        //traer todos las formulas del batch
                        Ds = new DataSet();
                        string empresa = "", sede = "001PU";
                        if (CboEmpresa.SelectedIndex == 0)
                        {
                            empresa = "IH";
                        }
                        else
                        {
                            empresa = "GH";
                        }

                        Ds = ObjCL_Produccion.GetMateriasPrimasHistorico(DtProductosBatch, Convert.ToInt32(LstHistorico.SelectedValue), empresa, sede);

                        #region Microinsumos
                        TcProduccion.SelectedIndex = 0;
                        TdgMicro.SetDataBinding(Ds.Tables["DtPlanProduccionMII"], "", false);

                        this.TdgMicro.Columns["Batch"].Caption = "Batch";
                        this.TdgMicro.Splits[0].DisplayColumns["Batch"].Style.Locked = true;
                        this.TdgMicro.Splits[0].DisplayColumns["Batch"].Visible      = true;
                        this.TdgMicro.Splits[0].DisplayColumns["Batch"].Width        = 100;
                        this.TdgMicro.Splits[0].DisplayColumns["Batch"].Merge        = ColumnMergeEnum.Free;

                        this.TdgMicro.Columns["ProductoID"].Caption = "ProductoID";
                        this.TdgMicro.Splits[0].DisplayColumns["ProductoID"].Style.Locked = true;
                        this.TdgMicro.Splits[0].DisplayColumns["ProductoID"].Visible      = false;
                        this.TdgMicro.Splits[0].DisplayColumns["ProductoID"].Width        = 280;
                        this.TdgMicro.Splits[0].DisplayColumns["ProductoID"].Merge        = ColumnMergeEnum.Free;

                        this.TdgMicro.Columns["NomProducto"].Caption = "Producto Terminado";
                        this.TdgMicro.Splits[0].DisplayColumns["NomProducto"].Style.Locked = true;
                        this.TdgMicro.Splits[0].DisplayColumns["NomProducto"].Visible      = true;
                        this.TdgMicro.Splits[0].DisplayColumns["NomProducto"].Width        = 250;
                        this.TdgMicro.Splits[0].DisplayColumns["NomProducto"].Merge        = ColumnMergeEnum.Free;

                        for (int x = 3; x < Ds.Tables["DtPlanProduccionMII"].Columns.Count; x++)
                        {
                            this.TdgMicro.Columns[Ds.Tables["DtPlanProduccionMII"].Columns[x].ColumnName].Caption      = Ds.Tables["DtPlanProduccionMII"].Columns[x].ColumnName;
                            this.TdgMicro.Columns[Ds.Tables["DtPlanProduccionMII"].Columns[x].ColumnName].NumberFormat = "FormatText Event";
                            this.TdgMicro.Splits[0].DisplayColumns[Ds.Tables["DtPlanProduccionMII"].Columns[x].ColumnName].Style.Locked = true;
                            this.TdgMicro.Splits[0].DisplayColumns[Ds.Tables["DtPlanProduccionMII"].Columns[x].ColumnName].Visible      = true;
                            this.TdgMicro.Splits[0].DisplayColumns[Ds.Tables["DtPlanProduccionMII"].Columns[x].ColumnName].Width        = 230;
                            //this.TdgMicro.Splits[0].DisplayColumns["NomProducto"].Merge = ColumnMergeEnum.Free;
                        }
                        TdgMicro.EmptyRows = true;
                        #endregion

                        #region Macroinsumos
                        TcProduccion.SelectedIndex = 1;
                        TdgMacro.SetDataBinding(Ds.Tables["DtPlanProduccionMAI"], "", false);

                        this.TdgMacro.Columns["Batch"].Caption = "Batch";
                        this.TdgMacro.Splits[0].DisplayColumns["Batch"].Style.Locked = true;
                        this.TdgMacro.Splits[0].DisplayColumns["Batch"].Visible      = true;
                        this.TdgMacro.Splits[0].DisplayColumns["Batch"].Width        = 100;
                        this.TdgMacro.Splits[0].DisplayColumns["Batch"].Merge        = ColumnMergeEnum.Free;

                        this.TdgMacro.Columns["ProductoID"].Caption = "ProductoID";
                        this.TdgMacro.Splits[0].DisplayColumns["ProductoID"].Style.Locked = true;
                        this.TdgMacro.Splits[0].DisplayColumns["ProductoID"].Visible      = false;
                        this.TdgMacro.Splits[0].DisplayColumns["ProductoID"].Width        = 280;
                        this.TdgMacro.Splits[0].DisplayColumns["ProductoID"].Merge        = ColumnMergeEnum.Free;

                        this.TdgMacro.Columns["NomProducto"].Caption = "Producto Terminado";
                        this.TdgMacro.Splits[0].DisplayColumns["NomProducto"].Style.Locked = true;
                        this.TdgMacro.Splits[0].DisplayColumns["NomProducto"].Visible      = true;
                        this.TdgMacro.Splits[0].DisplayColumns["NomProducto"].Width        = 250;
                        this.TdgMacro.Splits[0].DisplayColumns["NomProducto"].Merge        = ColumnMergeEnum.Free;

                        for (int x = 3; x < Ds.Tables["DtPlanProduccionMAI"].Columns.Count; x++)
                        {
                            this.TdgMacro.Columns[Ds.Tables["DtPlanProduccionMAI"].Columns[x].ColumnName].Caption      = Ds.Tables["DtPlanProduccionMAI"].Columns[x].ColumnName;
                            this.TdgMacro.Columns[Ds.Tables["DtPlanProduccionMAI"].Columns[x].ColumnName].NumberFormat = "FormatText Event";
                            this.TdgMacro.Splits[0].DisplayColumns[Ds.Tables["DtPlanProduccionMAI"].Columns[x].ColumnName].Style.Locked = true;
                            this.TdgMacro.Splits[0].DisplayColumns[Ds.Tables["DtPlanProduccionMAI"].Columns[x].ColumnName].Visible      = true;
                            this.TdgMacro.Splits[0].DisplayColumns[Ds.Tables["DtPlanProduccionMAI"].Columns[x].ColumnName].Width        = 230;
                            //this.TdgMacro.Splits[0].DisplayColumns["NomProducto"].Merge = ColumnMergeEnum.Free;
                        }
                        TdgMacro.EmptyRows = true;
                        #endregion
                    }
                    else
                    {
                        MessageBox.Show("No se ha agregado todavia ningun producto terminado o un Batch es igual a '0'.", "Error en Plan de produccion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        TcProduccion.SelectedIndex = 0;
                        DataTable dt1 = new DataTable();
                        DataTable dt2 = new DataTable();

                        TcProduccion.SelectedIndex = 0;
                        TdgMicro.SetDataBinding(dt1, "", true);
                        TcProduccion.SelectedIndex = 1;
                        TdgMacro.SetDataBinding(dt2, "", true);
                    }
                    #endregion
                    BtnProductoTerminado.Visible = true;
                }
                BtnGrabar.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }