private void formatgridNPI()
        {
            if (first)
            {
                _Helper = new MyCellMergeHelper(gvwView);
                first   = false;
            }
            _Helper.removeMerged();

            if (first)
            {
                _Helper = new MyCellMergeHelper(gvwView);
            }
            for (int irow = 0; irow < gvwView.RowCount; irow++)
            {
                if (irow % 3 == 0)
                {
                    for (int icol = 2; icol < gvwView.Columns.Count; icol++)
                    {
                        if (icol < gvwView.Columns.Count - 1)
                        {
                            _Helper.AddMergedCell(irow, icol, icol + 1, "");
                        }
                    }
                }
            }
        }
Example #2
0
        private void Format_Grid()
        {
            try
            {
                gvwBase.BeginUpdate();
                #region replace
                for (int i = 0; i <= gvwBase.RowCount - 1; i++)
                {
                    if (gvwBase.GetRowCellValue(i, gvwBase.Columns["CMP1"]).ToString() == "SET_ORDER")
                    {
                        gvwBase.SetRowCellValue(i, gvwBase.Columns["CMP1"], "Order By Set (Prs)");
                    }
                    if (gvwBase.GetRowCellValue(i, gvwBase.Columns["CMP2"]).ToString() == "SET_ORDER")
                    {
                        gvwBase.SetRowCellValue(i, gvwBase.Columns["CMP2"], "Order By Set (Prs)");
                    }


                    if (gvwBase.GetRowCellValue(i, gvwBase.Columns["CMP1"]).ToString() == "SET_OUT")
                    {
                        gvwBase.SetRowCellValue(i, gvwBase.Columns["CMP1"], "Outgoing By Set (Prs)");
                    }
                    if (gvwBase.GetRowCellValue(i, gvwBase.Columns["CMP2"]).ToString() == "SET_OUT")
                    {
                        gvwBase.SetRowCellValue(i, gvwBase.Columns["CMP2"], "Outgoing By Set (Prs)");
                    }

                    if (gvwBase.GetRowCellValue(i, gvwBase.Columns["CMP1"]).ToString() == "PER")
                    {
                        gvwBase.SetRowCellValue(i, gvwBase.Columns["CMP1"], "%");
                    }
                    if (gvwBase.GetRowCellValue(i, gvwBase.Columns["CMP2"]).ToString() == "PER")
                    {
                        gvwBase.SetRowCellValue(i, gvwBase.Columns["CMP2"], "%");
                    }

                    if (gvwBase.GetRowCellValue(i, gvwBase.Columns["CMP1"]).ToString() == "OUT_IN_ORDER")
                    {
                        gvwBase.SetRowCellValue(i, gvwBase.Columns["CMP1"], "Detail (Out = Order) ");
                    }
                    if (gvwBase.GetRowCellValue(i, gvwBase.Columns["CMP1"]).ToString() == "OUT_NOT_ORDER")
                    {
                        gvwBase.SetRowCellValue(i, gvwBase.Columns["CMP1"], "Detail (Out <> Order)");
                    }
                    if (gvwBase.GetRowCellValue(i, gvwBase.Columns["CMP2"]).ToString().Contains("Y"))
                    {
                        gvwBase.SetRowCellValue(i, gvwBase.Columns["CMP2"], gvwBase.GetRowCellValue(i, gvwBase.Columns["CMP2"]).ToString().Replace("-Y", ""));
                    }

                    if (gvwBase.GetRowCellValue(i, gvwBase.Columns["CMP2"]).ToString().Contains("N"))
                    {
                        gvwBase.SetRowCellValue(i, gvwBase.Columns["CMP2"], gvwBase.GetRowCellValue(i, gvwBase.Columns["CMP2"]).ToString().Replace("-N", ""));
                    }
                }

                #endregion replace

                _Helper = new MyCellMergeHelper(gvwBase);
                _Helper.AddMergedCell(0, 0, 1, "Order By Set (Prs)");
                _Helper.AddMergedCell(1, 0, 1, "Outgoing By Set (Prs)");
                _Helper.AddMergedCell(2, 0, 1, "%");


                for (int i = 0; i < gvwBase.Columns.Count; i++)
                {
                    gvwBase.Columns[i].AppearanceCell.Options.UseTextOptions = true;
                    gvwBase.Columns[i].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                    gvwBase.Columns[i].OptionsColumn.AllowMerge  = DevExpress.Utils.DefaultBoolean.True;
                    gvwBase.Columns[i].OptionsFilter.AllowFilter = false;
                    gvwBase.Columns[i].OptionsColumn.AllowSort   = DevExpress.Utils.DefaultBoolean.False;

                    gvwBase.ColumnPanelRowHeight = 25;
                    gvwBase.RowHeight            = 25;
                    gvwBase.Columns[i].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;

                    if (i <= 1)
                    {
                        gvwBase.Columns[i].Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left;
                        gvwBase.Columns[i].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.True;
                    }
                    else
                    {
                        gvwBase.Columns[i].OptionsColumn.AllowMerge   = DevExpress.Utils.DefaultBoolean.False;
                        gvwBase.Columns[i].DisplayFormat.FormatType   = DevExpress.Utils.FormatType.Numeric;
                        gvwBase.Columns[i].DisplayFormat.FormatString = "#,###.##";
                    }


                    gvwBase.Columns[i].Caption = gvwBase.Columns[i].FieldName.ToString().Replace("'", "");
                }
                gvwBase.Columns[0].Caption = gvwBase.Columns[0].FieldName.ToString().Replace("CMP1", "Item");
                gvwBase.Columns[1].Caption = gvwBase.Columns[1].FieldName.ToString().Replace("CMP2", "Div");

                gvwBase.Appearance.Row.Font = new System.Drawing.Font("DotumChe", 10F, System.Drawing.FontStyle.Regular);
                gvwBase.BestFitColumns();

                // gvwBase.OptionsView.ColumnAutoWidth = false;
                gvwBase.EndUpdate();
            }
            catch { }
        }
        //=====================================


        private void BindingData()
        {
            try
            {
                DataTable dtSource   = new DataTable();
                DataTable dtDays     = new DataTable();
                DataTable dtData     = new DataTable();
                DataTable dtQuantity = new DataTable();

                DataTable dt = null;
                dt = getTMSMilkrunOrder("Q1", V_Line, "", tripCD);
                if (dt.Rows.Count > 0 && dt != null)
                {
                    dtQuantity      = dt;
                    txtTripQty.Text = string.Format("{0:n0}", dtQuantity.Rows[0]["PRS_QTY"]);
                }
                dt = null;
                dt = getTMSMilkrunOrder("QH", V_Line, "", tripCD);
                if (dt.Rows.Count > 0 && dt != null)
                {
                    dtDays = dt;
                    BuildHeader(dtSource, dtDays);

                    dtData = null;

                    dtData = getTMSMilkrunOrder("Q", V_Line, "", tripCD);
                    if (dtData.Rows.Count > 0 && dtData != null)
                    {
                        tripCD = dtData.Rows[0]["CUR_TRIP"].ToString();
                        BindingDataSource(dtSource, dtDays, dtData);
                    }
                    txtTruck.Enabled = true;
                    if (V_Line.Equals("201"))
                    {
                        txtTruck.Text = "2,676";
                    }
                    else if (V_Line.Equals("202"))
                    {
                        txtTruck.Text = "1,308";
                    }
                    else
                    {
                        txtTruck.Text    = "";
                        txtTruck.Enabled = false;
                    }
                }
                grdBase.DataSource = dtSource;
                gvwBase.BeginUpdate();
                _Helper = new MyCellMergeHelper(gvwBase);


                for (int i = 0; i <= gvwBase.RowCount - 1; i += 5)
                {
                    gvwBase.SetRowCellValue(i, "DIV0", "Plan");
                    _Helper.AddMergedCell(i, 1, 2, "Plan");

                    gvwBase.SetRowCellValue(i + 1, "DIV0", "Total Out");
                    _Helper.AddMergedCell(i + 1, 1, 2, "Total Out");

                    //gvwBase.SetRowCellValue(i + 2, "DIV0", "Pre Trip");

                    gvwBase.SetRowCellValue(i + 2, "DIV0", "Current Trip: " + tripCD);
                    gvwBase.SetRowCellValue(i + 3, "DIV0", "Current Trip: " + tripCD);
                    gvwBase.SetRowCellValue(i + 4, "DIV0", "Current Trip: " + tripCD);
                }

                for (int i = 0; i < gvwBase.Columns.Count; i++)
                {
                    gvwBase.Columns[i].AppearanceCell.Options.UseTextOptions = true;
                    gvwBase.Columns[i].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                    gvwBase.Columns[i].OptionsColumn.AllowMerge  = DevExpress.Utils.DefaultBoolean.True;
                    gvwBase.Columns[i].OptionsFilter.AllowFilter = false;
                    gvwBase.Columns[i].OptionsColumn.AllowSort   = DevExpress.Utils.DefaultBoolean.False;
                    gvwBase.ColumnPanelRowHeight = 25;
                    gvwBase.RowHeight            = 25;

                    if (i < 3)
                    {
                        gvwBase.Columns[i].OwnerBand.Width = 50;
                    }
                    else
                    if (i >= 3)
                    {
                        gvwBase.Columns[i].OwnerBand.Width = 30;
                    }


                    if (i <= Array.IndexOf(headNames, "DIV"))
                    {
                        gvwBase.Columns[i].OwnerBand.Fixed          = DevExpress.XtraGrid.Columns.FixedStyle.Left;
                        gvwBase.Columns[i].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.True;
                    }
                    else
                    {
                        gvwBase.Columns[i].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.False;



                        if (gvwBase.Columns[i].FieldName.Contains("H"))
                        {
                            gvwBase.Columns[i].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;

                            gvwBase.Columns[i].DisplayFormat.FormatType   = DevExpress.Utils.FormatType.Numeric;
                            gvwBase.Columns[i].DisplayFormat.FormatString = "#,##0.##";
                            // gvwBase.Appearance.BandPanel.Font = new System.Drawing.Font("DotumChe", 7F, FontStyle.Regular);
                        }
                    }
                }
                gvwBase.Appearance.Row.Font = new System.Drawing.Font("Calibri", 11, System.Drawing.FontStyle.Regular);
                //  gvwBase.BestFitColumns();
                gvwBase.OptionsView.ColumnAutoWidth = false;
                gvwBase.EndUpdate();
                column_width();
                MarkTripButton();
            }
            catch (Exception ex)
            {
            }
        }
        private void BindingData(string _line_cd, string _mline_cd)
        {
            if (first)
            {
                _Helper = new MyCellMergeHelper(gridView1);
                first   = false;
            }
            //grid.Refresh();
            DataTable dtsource = null;

            grid.DataSource = dtsource;
            gridView1.Columns.Clear();
            dtsource = SEL_INVENTORY_SHORTAGE(_line_cd, _mline_cd, "UPS", "O", "UP");
            // formatband();
            grid.DataSource = dtsource;
            //for (int i = 0; i < 4; i++)
            //{
            //    gridView1.Columns[i].Caption = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(gridView1.Columns[i].GetCaption().Replace("_", " ").ToLower());
            //    gridView1.Columns[i].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            //    gridView1.Columns[i].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.True;
            //}
            gridView1.Columns[1].Width           = 190;
            gridView1.Columns[2].Width           = 90;
            gridView1.Columns[3].Width           = 70;
            gridView1.OptionsView.AllowCellMerge = true;
            for (int i = 0; i < gridView1.Columns.Count; i++)
            {
                gridView1.Columns[i].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.False;
                //gridView1.Columns[i].DisplayFormat.FormatString = "#,###,###";
                if (i <= 3)
                {
                    gridView1.Columns[i].Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left;
                }
            }
            gridView1.OptionsView.ColumnAutoWidth = true;
            gridView1.BestFitColumns();

            gridView1.TopRowIndex = gridView1.RowCount - 1;

            gridView1.Columns[0].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.True;
            gridView1.Columns[1].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.True;
            gridView1.Columns[2].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.True;
            //for (int i = 4; i < dtsource.Columns.Count; i++)
            //{
            //    gridView1.Columns[i].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;

            //}

            for (int i = 0; i < gridView1.Columns.Count; i++)
            {
                // gridView1.Columns[i].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.True;
                //if (i == 1)
                //{
                //    gridView1.Columns[i].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.True;
                //}
                if (i < 4)
                {
                    gridView1.Columns[i].Caption = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(gridView1.Columns[i].GetCaption().Replace("_", " ").ToLower());
                    gridView1.Columns[i].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                }
                else
                {
                    gridView1.Columns[i].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
                    //gridView1.Columns[i].DisplayFormat.FormatType = g;
                    // gridView1.Columns[i].Width = 60;
                }
            }


            _Helper.removeMerged();
            if (first)
            {
                _Helper = new MyCellMergeHelper(gridView1);
            }
            _Helper.AddMergedCell(gridView1.RowCount - 1, 0, 1, "");
            _Helper.AddMergedCell(gridView1.RowCount - 1, 1, 2, "");
            _Helper.AddMergedCell(gridView1.RowCount - 1, 2, 3, "");

            _Helper.AddMergedCell(gridView1.RowCount - 2, 0, 1, "");
            _Helper.AddMergedCell(gridView1.RowCount - 2, 1, 2, "");
            _Helper.AddMergedCell(gridView1.RowCount - 2, 2, 3, "");

            _Helper.AddMergedCell(gridView1.RowCount - 3, 0, 1, "");
            _Helper.AddMergedCell(gridView1.RowCount - 3, 1, 2, "");
            _Helper.AddMergedCell(gridView1.RowCount - 3, 2, 3, "");



            //if (dtsource != null && dtsource.Rows.Count > 0)
            //{

            //    for (int i = 0; i < grid.Columns.Count; i++)
            //    {
            //        grid.Columns[i].OptionsColumn.ReadOnly = true;
            //        grid.Columns[i].OptionsColumn.AllowEdit = false;
            //        grid.Columns[i].OptionsFilter.AllowFilter = false;
            //        grid.Columns[i].OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
            //        grid.Columns[i].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            //        grid.Columns[i].AppearanceCell.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
            //        if (i > 0)
            //        {
            //            grid.Columns[i].AppearanceCell.Font = new System.Drawing.Font("Calibri", 12, FontStyle.Bold);
            //        }

            //    }

            //}
        }
        private void BindingData(string _line_cd, string _mline_cd)
        {
            if (first)
            {
                _Helper = new MyCellMergeHelper(gridView1);
                first   = false;
            }
            grid.Refresh();
            DataTable dtsource = null;

            grid.DataSource = dtsource;
            gridView1.Columns.Clear();
            dtsource                             = SEL_INVENTORY_SHORTAGE(_line_cd, _mline_cd, "UPS", "O", "UP");
            grid.DataSource                      = dtsource;
            gridView1.Columns[0].Width           = 90;
            gridView1.Columns[1].Width           = 190;
            gridView1.Columns[2].Width           = 93;
            gridView1.Columns[3].Width           = 108;
            gridView1.OptionsView.AllowCellMerge = true;
            for (int i = 0; i < gridView1.Columns.Count; i++)
            {
                gridView1.Columns[i].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.False;
                if (i <= 3)
                {
                    gridView1.Columns[i].Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left;
                }
            }
            gridView1.TopRowIndex = gridView1.RowCount - 1;
            gridView1.Columns[0].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.True;
            gridView1.Columns[1].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.True;
            gridView1.Columns[2].OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.True;

            for (int i = 0; i < gridView1.Columns.Count; i++)
            {
                if (i < 4)
                {
                    gridView1.Columns[i].Caption = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(gridView1.Columns[i].GetCaption().Replace("_", " ").ToLower());
                    gridView1.Columns[i].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                }
                else
                {
                    gridView1.Columns[i].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
                }
            }
            _Helper.removeMerged();
            if (first)
            {
                _Helper = new MyCellMergeHelper(gridView1);
            }
            _Helper.AddMergedCell(gridView1.RowCount - 1, 0, 1, "");
            _Helper.AddMergedCell(gridView1.RowCount - 1, 1, 2, "");
            _Helper.AddMergedCell(gridView1.RowCount - 1, 2, 3, "");

            _Helper.AddMergedCell(gridView1.RowCount - 2, 0, 1, "");
            _Helper.AddMergedCell(gridView1.RowCount - 2, 1, 2, "");
            _Helper.AddMergedCell(gridView1.RowCount - 2, 2, 3, "");

            _Helper.AddMergedCell(gridView1.RowCount - 3, 0, 1, "");
            _Helper.AddMergedCell(gridView1.RowCount - 3, 1, 2, "");
            _Helper.AddMergedCell(gridView1.RowCount - 3, 2, 3, "");
        }