APP.cs 2.65 KB
using HHWCS.Model;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HHWCS.Common
{
    public class APP
    {
        public static String ConnectionString = ConfigurationManager.ConnectionStrings["MySql"].ConnectionString;

        public static MySqlConnection MysqlConnection = new MySqlConnection(ConnectionString);

        public static String Origin = ConfigurationManager.AppSettings["origin"];

        public static User User { get; set; }

        /// <summary>
        /// DataGridView格式化
        /// </summary>
        /// <param name="dv">DataGridView控制</param>
        public static void FormatDgv2(DataGridView dv)
        {
            #region

            dv.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(231, 235, 247);
            dv.GridColor = Color.FromArgb(148, 190, 231);
            dv.DefaultCellStyle.BackColor = Color.FromArgb(239, 243, 255);

            dv.DefaultCellStyle.SelectionBackColor = Color.Blue;
            dv.RowHeadersWidth = 4;
            //dv.BackgroundColor = Color.Honeydew;
            dv.BackgroundColor = Color.FromArgb(200, 212, 200);//FromArgb(200, 198, 200)
            dv.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(200, 230, 200);

            //可以改变表格线条风格
            //dv.GridColor = Color.BlueViolet;
            dv.BorderStyle = BorderStyle.Fixed3D;
            dv.EditMode = DataGridViewEditMode.EditProgrammatically;
            dv.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
            dv.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
            dv.AutoGenerateColumns = false;
            //dv.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;//AllCells  //DisplayedCells
            //dv.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
            #endregion
        }

        internal static String GetTaskType(String v)
        {
            switch (v)
            {
                case "100": return "整盘入库";
                case "200": return "补充入库";
                case "300": return "整盘出库";
                case "400": return "分拣出库";
                case "500": return "空容器入库";
                case "600": return "空容器出库"; 
                case "700": return "盘点";
                case "800": return "移库";
                case "900": return "出库查看";
            }
            return "未识别的任务类型";
        }
    }
}