예제 #1
0
        public FormProductPlanPreview( )
        {
            InitializeComponent( );

            _bll  = new LineProductMesBll.Bll.ProductPlanPreviewBll( );
            model = new LineProductMesEntityu.ProductPlanPreviewEntity( );

            GridViewMoHuSelect.SetFilter(new DevExpress.XtraGrid.Views.Grid.GridView [] { gridView1, View1 });
            GrivColumnStyle.setColumnStyle(new DevExpress.XtraGrid.Views.Grid.GridView [] { gridView1, View1 });
            FieldInfo fi = typeof(XPaint).GetField("graphics", BindingFlags.Static | BindingFlags.NonPublic);

            fi.SetValue(null, new DrawXPaint( ));

            ToolBarContain.ToolbarsC(barTool, new DevExpress.XtraBars.BarItem [] { toolPrint, toolExamin, toolDelete });

            dt           = LineProductMesBll.UserInfoMation.sysTime;
            dtStart.Text = dt.ToString("yyyy-MM-dd");
            dtEnd.Text   = Convert.ToDateTime(dt).AddMonths(3).ToString("yyyy-MM-dd");

            txtPRE.Properties.DataSource    = _bll.getProPlanInfo( );
            txtPRE.Properties.DisplayMember = "DEA002";
            txtPRE.Properties.ValueMember   = "PRE004";

            toolCancellation.Caption = "产线排产";

            table = new DataTable( );
            table.Columns.Add("P1", typeof(System.String));
            table.Columns.Add("P2", typeof(System.String));
            table.Columns.Add("P3", typeof(System.DateTime));
            table.Columns.Add("P4", typeof(System.DateTime));
            table.Columns.Add("P5", typeof(System.Int32));
            table.Columns.Add("P6", typeof(System.Int32));

            controlUnEnable( );
        }
예제 #2
0
        /// <summary>
        /// 批量增加排产天数
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public bool SaveDay(DataTable table)
        {
            Dictionary <object, object> SQLString = new Dictionary <object, object> ( );
            StringBuilder strSql = new StringBuilder( );

            LineProductMesEntityu.ProductPlanPreviewEntity model = new LineProductMesEntityu.ProductPlanPreviewEntity( );

            int days = 0;

            foreach (DataRow row in table.Rows)
            {
                model.PRF001 = row ["P1"].ToString( );
                model.PRF003 = 0;
                days         = string.IsNullOrEmpty(row ["P5"].ToString( )) == true ? 0 : Convert.ToInt32(row ["P5"]);
                model.PRF002 = getTime(model.PRF001);
                if (model.PRF002 == null)
                {
                    continue;
                }
                for (int i = 0; i < days; i++)
                {
                    model.PRF002 = Convert.ToDateTime(model.PRF002).AddDays(1);
                    Addprf(SQLString, model);
                }
            }

            return(SqlHelper.ExecuteSqlTranDic(SQLString));
        }
예제 #3
0
        /// <summary>
        /// 读取排产数据
        /// </summary>
        /// <returns></returns>
        public bool ReadPlanData( )
        {
            Dictionary <object, object> SQLString = new Dictionary <object, object> ( );

            StringBuilder strSql = new StringBuilder( );

            strSql.Append("SELECT PRE004,PRE005,SUM(PRE008) PRE008 FROM MIKPRD A INNER JOIN MIKPRE B ON A.PRD001=B.PRE001 WHERE PRD003=0 GROUP BY PRE004,PRE005 ORDER BY PRE004,PRE005");

            DataTable table = SqlHelper.ExecuteDataTable(strSql.ToString( ));

            if (table == null || table.Rows.Count < 1)
            {
                return(true);
            }

            strSql = new StringBuilder( );
            strSql.Append("SELECT PRF001,PRF002,PRF003 FROM MIKPRF ORDER BY PRF001");
            DataTable tableOne = SqlHelper.ExecuteDataTable(strSql.ToString( ));

            bool result = true;

            if (tableOne == null || tableOne.Rows.Count < 1)
            {
                result = false;
            }

            LineProductMesEntityu.ProductPlanBodyEntity    model  = new LineProductMesEntityu.ProductPlanBodyEntity( );
            LineProductMesEntityu.ProductPlanPreviewEntity entity = new LineProductMesEntityu.ProductPlanPreviewEntity( );
            foreach (DataRow row in table.Rows)
            {
                model.PRE004 = row ["PRE004"].ToString( );
                model.PRE005 = Convert.ToDateTime(row ["PRE005"]);
                model.PRE008 = Convert.ToInt32(row ["PRE008"]);
                if (result == false)
                {
                    Addprf(SQLString, model);
                }
                else
                {
                    if (tableOne.Select("PRF001='" + model.PRE004 + "' AND PRF002='" + model.PRE005 + "'").Length < 1)
                    {
                        Addprf(SQLString, model);
                    }
                    else
                    {
                        Editprf(SQLString, model);
                    }
                }
            }

            return(SqlHelper.ExecuteSqlTranDic(SQLString));
        }
예제 #4
0
        void Editprf(Dictionary <object, object> SQLString, LineProductMesEntityu.ProductPlanPreviewEntity model)
        {
            StringBuilder strSql = new StringBuilder( );

            strSql.Append("update MIKPRF set ");
            strSql.Append("PRF003=@PRF003 ");
            strSql.Append("WHERE PRF001=@PRF001 AND PRF002=@PRF002");
            SqlParameter [] parameters =
            {
                new SqlParameter("@PRF001", SqlDbType.NVarChar, 20),
                new SqlParameter("@PRF002", SqlDbType.Date,      3),
                new SqlParameter("@PRF003", SqlDbType.Int, 4)
            };
            parameters [0].Value = model.PRF001;
            parameters [1].Value = model.PRF002;
            parameters [2].Value = model.PRF003;
            SQLString.Add(strSql, parameters);
        }
예제 #5
0
        void Addprf(Dictionary <object, object> SQLString, LineProductMesEntityu.ProductPlanPreviewEntity model)
        {
            StringBuilder strSql = new StringBuilder( );

            strSql.Append("insert into MIKPRF(");
            strSql.Append("PRF001,PRF002,PRF003)");
            strSql.Append(" values (");
            strSql.Append("@PRF001,@PRF002,@PRF003)");
            SqlParameter [] parameters =
            {
                new SqlParameter("@PRF001", SqlDbType.NVarChar, 20),
                new SqlParameter("@PRF002", SqlDbType.Date,      3),
                new SqlParameter("@PRF003", SqlDbType.Int, 4)
            };
            parameters [0].Value = model.PRF001;
            parameters [1].Value = model.PRF002;
            parameters [2].Value = model.PRF003;
            SQLString.Add(strSql, parameters);
        }
예제 #6
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public bool Save(DataTable table)
        {
            StringBuilder strSql = new StringBuilder( );

            strSql.Append("SELECT PRF001,PRF002,PRF003 FROM MIKPRF ORDER BY PRF001");
            DataTable tableOne = SqlHelper.ExecuteDataTable(strSql.ToString( ));

            Dictionary <object, object> SQLString = new Dictionary <object, object> ( );

            LineProductMesEntityu.ProductPlanPreviewEntity model = new LineProductMesEntityu.ProductPlanPreviewEntity( );
            foreach (DataRow row in table.Rows)
            {
                foreach (DataColumn column in table.Columns)
                {
                    if (column.ColumnName == "主件品号")
                    {
                        model.PRF001 = row [column].ToString( );
                    }
                    else if (column.ColumnName != "主件品名" && column.ColumnName != "TOTAL" && column.ColumnName != "生产车间" && column.ColumnName != "仓库" && column.ColumnName != "单位" && column.ColumnName != "排产量" && column.ColumnName != "订单未交量" && column.ColumnName != "预计生产量" && column.ColumnName != "库存量" && column.ColumnName != "库存可用量" && column.ColumnName != "未排量" && column.ColumnName != "开单未入量" && column.ColumnName != "客户名称")
                    {
                        model.PRF002 = Convert.ToDateTime(column.ColumnName);
                        //if ( row [ column ] != null && row [ column ] . ToString ( ) != string . Empty )
                        //{
                        model.PRF003 = string.IsNullOrEmpty(row [column].ToString( )) == true?0: Convert.ToInt32(row [column]);
                        if (tableOne != null && tableOne.Rows.Count > 0)
                        {
                            if (tableOne.Select("PRF001='" + model.PRF001 + "' AND PRF002='" + model.PRF002 + "'").Length < 1)
                            {
                                Addprf(SQLString, model);
                            }
                            else
                            {
                                Editprf(SQLString, model);
                            }
                        }
                        //}
                    }
                }
            }

            return(SqlHelper.ExecuteSqlTranDic(SQLString));
        }