Exemplo n.º 1
0
        private void Search()
        {
            string    strWhere = GetConduction();
            DataTable dt       = bProductionPlanSearch.GetProductionPlan(strWhere).Tables[0];

            if (dt.Rows.Count < 1)
            {
                txtSlipNumber.Clear();
                txtOrder.Clear();
                dgvData.DataSource = dt;
                MessageBox.Show("查询的信息不存在!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                dgvData.DataSource = dt;
            }
            decimal weight = 0;

            foreach (DataRow row in dt.Rows)
            {
                weight += CConvert.ToDecimal(row["WEIGHT"].ToString());
            }
            txtTotal.Text = weight.ToString();
        }
Exemplo n.º 2
0
        private void dgvData_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            DataGridView dgv = (DataGridView)(sender);

            if (e.RowIndex != -1)
            {
                if (e.ColumnIndex == 0)
                {
                    DataGridViewRow row = dgv.Rows[e.RowIndex];
                    //
                    row.Cells["NO"].Value = e.RowIndex + 1;
                }
                //dgvProduction绑定数据
                DataGridViewRow rowline = dgvData.CurrentRow;
                label4.Text = rowline.Cells["TYPE_NAME"].Value.ToString();
                DataSet ds = bProductionPlanSearch.GetProductionPlan(" SLIP_NUMBER = '" + rowline.Cells["SLIP_NUMBER"].Value.ToString() + "'" + " AND LINE_NUMBER = '" + rowline.Cells["LINE_NUMBER"].Value.ToString() + "'");
                dgvProduction.DataSource = ds.Tables[0];
                foreach (DataGridViewRow dr in dgvProduction.Rows)
                {
                    if (dr.Cells["PSPP_ACTUAL_END_DATE"].Value.ToString() != "")
                    {
                        if (CConvert.ToDateTime(dr.Cells["PSPP_PLAN_END_DATE"].Value.ToString()) == CConvert.ToDateTime(dr.Cells["PSPP_ACTUAL_END_DATE"].Value.ToString()))
                        {
                            dr.Cells["DelayTimeProduction"].Value = "0天";
                        }
                        else if (CConvert.ToDateTime(dr.Cells["PSPP_PLAN_END_DATE"].Value.ToString()) > CConvert.ToDateTime(dr.Cells["PSPP_ACTUAL_END_DATE"].Value.ToString()))
                        {
                            dr.Cells["DelayTimeProduction"].Value = "0天";
                        }
                        else if (CConvert.ToDateTime(dr.Cells["PSPP_PLAN_END_DATE"].Value.ToString()) < CConvert.ToDateTime(dr.Cells["PSPP_ACTUAL_END_DATE"].Value.ToString()))
                        {
                            string dateDiff = null;

                            TimeSpan ts1 = new TimeSpan(CConvert.ToDateTime(dr.Cells["PSPP_PLAN_END_DATE"].Value.ToString()).Ticks);
                            TimeSpan ts2 = new TimeSpan(CConvert.ToDateTime(dr.Cells["PSPP_ACTUAL_END_DATE"].Value.ToString()).Ticks);
                            TimeSpan ts  = ts1.Subtract(ts2).Duration();
                            dateDiff = ts.Days.ToString() + "天";
                            //+ ts.Hours.ToString() + "小时"
                            // + ts.Minutes.ToString() + "分钟"
                            // + ts.Seconds.ToString() + "秒";
                            dr.Cells["DelayTimeProduction"].Value = dateDiff;
                        }
                    }
                    else
                    {
                        if (CConvert.ToDateTime(dr.Cells["PSPP_PLAN_END_DATE"].Value.ToString()) == CConvert.ToDateTime(DateTime.Now.ToString()))
                        {
                            dr.Cells["DelayTimeProduction"].Value = "0天";
                        }
                        else if (CConvert.ToDateTime(dr.Cells["PSPP_PLAN_END_DATE"].Value.ToString()) > CConvert.ToDateTime(DateTime.Now.ToString()))
                        {
                            dr.Cells["DelayTimeProduction"].Value = "0天";
                        }
                        else if (CConvert.ToDateTime(dr.Cells["PSPP_PLAN_END_DATE"].Value.ToString()) < CConvert.ToDateTime(DateTime.Now.ToString()))
                        {
                            string dateDiff = null;

                            TimeSpan ts1 = new TimeSpan(CConvert.ToDateTime(dr.Cells["PSPP_PLAN_END_DATE"].Value.ToString()).Ticks);
                            TimeSpan ts2 = new TimeSpan(CConvert.ToDateTime(DateTime.Now.ToString()).Ticks);
                            TimeSpan ts  = ts1.Subtract(ts2).Duration();
                            dateDiff = ts.Days.ToString() + "天";
                            dr.Cells["DelayTimeProduction"].Value = dateDiff;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void Search()
        {
            string strWhere = GetConduction();

            dt = bProductionPlanSearch.GetProductionPlan(strWhere).Tables[0];
            dt.Columns.Add("TECHNOLOGY_STATUS", Type.GetType("System.String"));
            dt.Columns.Add("BTN_DOWN_LOAD", Type.GetType("System.String"));
            if (dt.Rows.Count < 1)
            {
                txtSlipNumber.Clear();
                txtSlipType.Clear();
                txtSlipTypeName.Clear();
                cboStatus.SelectedIndex = 0;
                txtSlipDateFrom.Checked = false;
                txtSlipDateTo.Checked   = false;
                dateTimePicker1.Checked = false;
                dateTimePicker2.Checked = false;
                //dgvData.DataSource = dt;
                dgvData.Rows.Clear();
                MessageBox.Show("查询的信息不存在!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                Hashtable dwHt         = new Hashtable();
                Hashtable technologyHt = new Hashtable();
                DataTable dtTechnology = bProductionPlanSearch.GetProductionTechnologyStatus(GetConductionTechnology()).Tables[0];
                DataTable dtDw         = bProductionPlanSearch.GetProductionDw(GetConductionDw()).Tables[0];

                //技术判断是否结束
                foreach (DataRow dr in dtTechnology.Rows)
                {
                    string key    = CConvert.ToString(dr["SLIP_NUMBER"]) + CConvert.ToString(dr["SCHEDULE_LINE_NUNBER"]) + CConvert.ToString(dr["LINE_NUMBER"]);
                    int    count  = CConvert.ToInt32(dr["COUNT"]);
                    int    number = CConvert.ToInt32(dr["NUMBER"]);
                    if (count == number)
                    {
                        technologyHt.Add(key, "结束");
                    }
                    else if (number == 0)
                    {
                        technologyHt.Add(key, "未开始");
                    }
                    else if (count > number)
                    {
                        technologyHt.Add(key, "已开始");
                    }
                }

                //图纸判断有无
                foreach (DataRow dr in dtDw.Rows)
                {
                    string key    = CConvert.ToString(dr["SLIP_NUMBER"]) + CConvert.ToString(dr["SCHEDULE_LINE_NUNBER"]) + CConvert.ToString(dr["LINE_NUMBER"]);
                    int    count  = CConvert.ToInt32(dr["COUNT"]);
                    int    number = CConvert.ToInt32(dr["NUMBER"]);
                    if (count >= number && number != 0)
                    {
                        dwHt.Add(key, "有");
                    }
                    else if (number == 0)
                    {
                        dwHt.Add(key, "无");
                    }
                }

                //
                foreach (DataRow dr in dt.Rows)
                {
                    if (dr["PSPP_STATUS_FLAG"].ToString() == CConvert.ToString(CConstant.STATUS))
                    {
                        dr["PSPP_ACTUAL_START_TIME"] = DateTime.Now;
                    }
                    else if (dr["PSPP_STATUS_FLAG"].ToString() == CConvert.ToString(CConstant.STATUS_START))
                    {
                        dr["PSPP_ACTUAL_END_TIME"] = DateTime.Now;
                    }

                    if (dr["PSPP_STATUS_FLAG"].ToString() == CConvert.ToString(CConstant.STATUS_END))
                    {
                        dr["TECHNOLOGY_STATUS"] = "结束";
                        //dr["BTN_DOWN_LOAD"] = "结束";
                    }
                    //else
                    //{
                    //
                    string key = CConvert.ToString(dr["SLIP_NUMBER"]) + CConvert.ToString(dr["SCHEDULE_LINE_NUNBER"]) + CConvert.ToString(dr["PSPP_LINE_NUMBER"]);
                    if (technologyHt.Contains(key))
                    {
                        dr["TECHNOLOGY_STATUS"] = technologyHt[key];
                    }
                    else
                    {
                        dr["TECHNOLOGY_STATUS"] = "N/A";
                    }
                    if (dwHt.Contains(key))
                    {
                        dr["BTN_DOWN_LOAD"] = dwHt[key];
                    }
                    else
                    {
                        dr["BTN_DOWN_LOAD"] = "N/A";
                    }
                    //
                    //}
                }

                //dgvData.DataSource = dt;
                try
                {
                    if (dgvData.Rows.Count > 0)
                    {
                        dgvData.Rows.Clear();
                    }
                    foreach (DataRow dr in dt.Rows)
                    {
                        int             currentRowIndex = dgvData.Rows.Add(1);
                        DataGridViewRow row             = dgvData.Rows[currentRowIndex];
                        row.Cells["SLIP_NUMBER"].Value             = dr["SLIP_NUMBER"];
                        row.Cells["TYPE_NAME"].Value               = dr["SLIP_TYPE_NAME"];
                        row.Cells["PARTS_NAME"].Value              = dr["PARTS_NAME"];
                        row.Cells["PRODUCTION_PROCESS_NAME"].Value = dr["PRODUCTION_PROCESS_NAME"];
                        row.Cells["BTN_DOWN_LOAD"].Value           = dr["BTN_DOWN_LOAD"];
                        row.Cells["TECHNOLOGY_STATUS"].Value       = dr["TECHNOLOGY_STATUS"];
                        row.Cells["START_PLAN_DATE"].Value         = dr["PSPP_PLAN_START_DATE"];
                        row.Cells["END_PLAN_DATE"].Value           = dr["PSPP_PLAN_END_DATE"];
                        row.Cells["PSPP_ACTUAL_START_TIME"].Value  = dr["PSPP_ACTUAL_START_TIME"];
                        row.Cells["PSPP_ACTUAL_END_TIME"].Value    = dr["PSPP_ACTUAL_END_TIME"];
                        row.Cells["WEIGHT"].Value = dr["WEIGHT"];
                        row.Cells["PRODUCTION_PROCESS_CODE"].Value = dr["PRODUCTION_PROCESS_CODE"];
                        row.Cells["SCHEDULE_LINE_NUNBER"].Value    = dr["SCHEDULE_LINE_NUNBER"];
                        row.Cells["PSPP_LINE_NUMBER"].Value        = dr["PSPP_LINE_NUMBER"];
                        row.Cells["PSPP_STATUS_FLAG"].Value        = dr["PSPP_STATUS_FLAG"];
                        row.Cells["PARTS_CODE"].Value     = dr["PARTS_CODE"];
                        row.Cells["PROCESS_STATUS"].Value = dr["PROCESS_STATUS"];
                    }
                }
                catch (Exception ex)
                { }

                foreach (DataGridViewRow dgvr in dgvData.Rows)
                {
                    if (dgvr.Cells["PROCESS_STATUS"].Value.ToString().Equals("0"))
                    {
                        dgvr.Cells["WEIGHT"].ReadOnly = true;
                    }
                    if (dgvr.Cells["PSPP_STATUS_FLAG"].Value.ToString() == CConvert.ToString(CConstant.STATUS))
                    {
                        dgvr.Cells["PSPP_ACTUAL_END_TIME"].ReadOnly = true;
                    }
                    if (dgvr.Cells["PSPP_STATUS_FLAG"].Value.ToString() == CConvert.ToString(CConstant.STATUS_START))
                    {
                        dgvr.Cells["PSPP_ACTUAL_START_TIME"].ReadOnly = true;
                    }

                    if ("2".Equals(CConvert.ToString(dgvr.Cells["PSPP_STATUS_FLAG"].Value)))
                    {
                        dgvr.Cells["CHK"].ReadOnly = true;
                        dgvr.Cells["PSPP_ACTUAL_START_TIME"].ReadOnly = true;
                        dgvr.Cells["PSPP_ACTUAL_END_TIME"].ReadOnly   = true;
                        dgvr.Cells["WEIGHT"].ReadOnly = true;
                    }
                    #region delete
                    //string _oldSlipNumber = dgvData.Rows[i].Cells["SLIP_NUMBER"].Value.ToString();
                    //string productionProcessCode = dgvData.Rows[i].Cells["PRODUCTION_PROCESS_CODE"].Value.ToString();
                    //Hashtable dwHt = new Hashtable();
                    //DataTable productionProcessDt = bProductionProcess.GetList(" CODE = '" + productionProcessCode + "'").Tables[0];
                    //foreach (DataRow dr in productionProcessDt.Rows)
                    //{
                    //    for (int l = 1; l <= 6; l++)
                    //    {
                    //        string dwCode = CConvert.ToString(dr["DRAWING_TYPE_CODE" + l]);
                    //        if (string.IsNullOrEmpty(dwCode))
                    //        {
                    //            continue;
                    //        }
                    //        if (dwHt.ContainsKey(dwCode))
                    //        {

                    //        }
                    //        else
                    //        {
                    //            dwHt.Add(dwCode, "");
                    //        }

                    //    }
                    //}

                    //foreach (DictionaryEntry de in dwHt)
                    //{
                    //    DataTable drawingDt = new DataTable();
                    //    string drawingcode = de.Key.ToString();
                    //    drawingDt = bproductionDrawing.GetProductionDrawingUpload(" SLIP_NUMBER = '" + _oldSlipNumber + "'" + " AND DRAWING_CODE = '" + drawingcode + "'").Tables[0];

                    //    if (drawingDt.Rows.Count > 0)
                    //    {
                    //        dgvData.Rows[i].Cells["BTN_DOWN_LOAD"].Value = "有";
                    //        break;
                    //    }
                    //    else
                    //    {
                    //        dgvData.Rows[i].Cells["BTN_DOWN_LOAD"].Value = "无";
                    //    }

                    //}
                    #endregion
                }
            }
        }
Exemplo n.º 4
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            foreach (Control ctl in this.Controls)
            {
                try
                {
                    // Attempt to cast the control to type MdiClient.
                    MdiClient ctlMDI = (MdiClient)ctl;

                    // Set the BackColor of the MdiClient control.
                    ctlMDI.BackColor = this.BackColor;
                }
                catch (InvalidCastException exc)
                {
                    // Catch and ignore the error if casting failed.
                }
            }

            lblUserName.Text       = _userInfo.NAME;
            lblDepartmentName.Text = _userInfo.DEPARTMENT_NAME;
            lblCompanyName.Text    = _userInfo.COMPANY_NAME;

            try
            {
                CCacheData.SetRolesFunction(_userInfo.ROLES_CODE);
            }
            catch { }
            //我的桌面的重新整理
            try
            {
                bCommon.ReSetMyDesk(_userInfo.COMPANY_CODE, _userInfo.CODE, _userInfo.ROLES_CODE);
            }
            catch (Exception ex)
            {
                Logger.Error("我的桌面的重新整理异常!", ex);
            }

            menuManage_Click(this.menuDesk, null);

            #region 通知

            BProductionPlanSearch bProductionPlanSearch = new BProductionPlanSearch();
            BProductionDrawing    bProductionDrawing    = new BProductionDrawing();
            try
            {
                int a = bProductionPlanSearch.GetProductionPlan(" DEPARTMENT_CODE = '" + _userInfo.DEPARTMENT_CODE + "'" + "  AND PSPP_STATUS_FLAG <> 2" + "  AND STATUS_FLAG <> 5").Tables[0].Rows.Count;
                int b = bProductionPlanSearch.GetProductionTechnology(" DEPARTMENT_CODE = '" + _userInfo.DEPARTMENT_CODE + "'" + "  AND PST_STATUS_FLAG <> 1" + "  AND STATUS_FLAG <> 5").Tables[0].Rows.Count;
                if (CConvert.ToInt32(a + b) > 0)
                {
                    menuProduceManage.Image           = Resources.warning;
                    menuProduceManage.BackgroundImage = null;
                    menuProduceManage.Top             = menuProduceManage.Top - 1;
                    menuProduceManage.Left            = menuProduceManage.Left - 1;
                }
                else if (_userInfo.DEPARTMENT_CODE.Equals("D05"))
                {
                    int c = bProductionDrawing.GetProductionDrawing("PSDL_STATUS_FLAG <> 1" + " AND PS_STATUS_FLAG <> 5").Tables[0].Rows.Count;
                    if (c > 0)
                    {
                        menuProduceManage.Image           = Resources.warning;
                        menuProduceManage.BackgroundImage = null;
                        menuProduceManage.Top             = menuProduceManage.Top - 1;
                        menuProduceManage.Left            = menuProduceManage.Left - 1;
                    }
                }
                else
                {
                    menuProduceManage.Image           = null;
                    menuProduceManage.BackgroundImage = Resources.buttonup;
                }
            }
            catch (Exception ex) { }


            ////入库预定
            //int receivingCount = 0;
            //try
            //{
            //    receivingCount = (new BReceipt()).GetRecordCount(" STATUS_FLAG =" + CConstant.INIT + " and DUE_DATE<= '" + DateTime.Now.ToString("yyyy-MM-dd") + "' ");
            //}
            //catch { }
            //if (receivingCount > 0)
            //{
            //    notifyMessage += "您有未处理的入库预定!\r\n";
            //}

            ////安全库存
            //int stockCount = 0;
            //try
            //{
            //    stockCount = (new BStock()).GetStockNotifyRecordCount(" STATUS_FLAG <> " + CConstant.DELETE + "and QUANTITY < SAFETY_STOCK ");
            //}
            //catch { }

            //if (stockCount > 0)
            //{
            //    notifyMessage += "商品库存不足,请尽快采购!\r\n";
            //}

            ////通知提示
            //if (notifyMessage != "")
            //{
            //    Thread notifyThread = new Thread(new ThreadStart(ShowNotify));
            //    notifyThread.Start();
            //}
            #endregion

            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmMain_FormClosing);
            this.FormClosed  += new System.Windows.Forms.FormClosedEventHandler(this.FrmMain_FormClosed);
        }