DataTable planDt;                                  //工单数据流
 /// <summary>
 /// 刷新DataGridView组件的数据
 /// </summary>
 public void ReflshDataGridView()
 {
     planDt = null;
     planDt = AsmPlan_BLL.GetFinishPlansByCondition(" ORDER BY PPP.DT DESC ");
     DGV_Plan.DataSource = planDt;
     DGV_Plan.ClearSelection();
 }
Exemple #2
0
 /// <summary>
 /// 向上移动
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BT_Down_Click(object sender, EventArgs e)
 {
     if (this.DGV_Plan.CurrentRow == null)
     {
         MessageBox.Show("请选择要需要操作的步序所在行");
     }
     else
     {
         int row = DGV_Plan.SelectedRows[0].Index;
         if (row <= 0)
         {
             MessageBox.Show("此步序已在顶端,不能再上移!");
         }
         else
         {
             AsmPlanObject apo = AsmPlan_BLL.GetPlanObjectByCondition(" WHERE ID=" + Convert.ToInt32(planDt.Rows[row]["ID"].ToString()));
             apo.PLAN_LEVEL = apo.PLAN_LEVEL - 1;
             AsmPlanObject apo_1 = AsmPlan_BLL.GetPlanObjectByCondition("WHERE ID=" + Convert.ToInt32(planDt.Rows[row - 1]["ID"].ToString()));
             apo_1.PLAN_LEVEL = apo_1.PLAN_LEVEL + 1;
             if (AsmPlan_BLL.UpdatePlan(apo) > 0 && AsmPlan_BLL.UpdatePlan(apo_1) > 0)
             {
                 ReflshDataGridView();
                 DGV_Plan.ClearSelection();
                 DGV_Plan.Rows[row - 1].Selected = true;
             }
             else
             {
                 MessageBox.Show("上移失败!");
             }
         }
     }
 }
Exemple #3
0
        public void ReflshDataGridView()
        {
            DataGridViewComboBoxColumn columnCbx = ((DataGridViewComboBoxColumn)DGV_Plan.Columns["operation"]);

            columnCbx.ValueMember   = "VALUE";
            columnCbx.DisplayMember = "NAME";
            columnCbx.DataSource    = CategoryDt;

            planDt = null;
            planDt = AsmPlan_BLL.GetPlansByCondition(" ORDER BY RPP.PLAN_LEVEL ASC ");
            DGV_Plan.DataSource = planDt;
            //   DGV_Plan.ClearSelection();
        }
Exemple #4
0
        /// <summary>
        /// 窗体加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PrintManager_Load(object sender, EventArgs e)
        {
            DataTable dt = AsmPlan_BLL.GetPlanObjectByConditionToPrint();

            LoadSource(dt);
            dic_year  = SetYearRule();
            dic_month = SetMonthRule();

            lb_LINE_ID.DataSource    = AsmLine_BLL.GetAllLines();
            lb_LINE_ID.DisplayMember = "NAME";
            lb_LINE_ID.ValueMember   = "ID";
            lb_LINE_ID.SelectedIndex = -1;
        }
Exemple #5
0
        private void BT_Save_Click(object sender, EventArgs e)
        {
            DataTable dtX = AsmPlan_BLL.GetPlanByName(TB_PlanNumber.Text.ToString().Trim());

            if (!(dtX.Rows.Count > 0))
            {
                if (!String.IsNullOrEmpty(CB_Line.SelectedItem.ToString()) && !String.IsNullOrEmpty(TB_PlanNumber.Text) && !String.IsNullOrEmpty(CB_ProductionType.SelectedItem.ToString()) && !String.IsNullOrEmpty(UD_ProductionNumber.Value.ToString()) && !String.IsNullOrEmpty(TB_OperationUser.Text))
                {
                    AsmPlanObject apo = new AsmPlanObject();
                    apo.LINE_ID             = Convert.ToInt32(CB_Line.SelectedValue);
                    apo.DT                  = DateTime.Now;
                    apo.NAME                = TB_PlanNumber.Text;
                    apo.PRODUCTION_ID       = Convert.ToInt32(CB_ProductionType.SelectedValue);
                    apo.NUMBER              = Convert.ToInt32(UD_ProductionNumber.Value);
                    apo.OPREATION_USER      = TB_OperationUser.Text;
                    apo.COMPLETE_FLAG       = "0";//表示初始化
                    apo.CREATE_BARCODE_FLAG = "0";
                    DataTable dt = AsmPlan_BLL.GetMaxLevelPlanByCondition();
                    if (dt.Rows.Count > 0 && !String.IsNullOrEmpty(dt.Rows[0]["LEVEL"].ToString()))
                    {
                        apo.PLAN_LEVEL = Convert.ToInt32(dt.Rows[0]["LEVEL"].ToString()) + 1;
                    }
                    else
                    {
                        apo.PLAN_LEVEL = 1;
                    }
                    if (AsmPlan_BLL.AddPlan(apo) > 0)
                    {
                        MessageBox.Show("保存成功!");
                        TB_PlanNumber.Text        = "";
                        UD_ProductionNumber.Value = 1;
                        TB_OperationUser.Text     = "";
                        ReflshDataGridView();
                    }
                    else
                    {
                        MessageBox.Show("保存失败,请检查输入信息是否正确!");
                    }
                }
                else
                {
                    MessageBox.Show("输入信息不全,请检查后保存!");
                }
            }
            else
            {
                MessageBox.Show("工单编号有重复!请重新输入");
            };
        }
Exemple #6
0
        /// <summary>
        /// button按钮的点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dGV_Print_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                string buttonText = this.dGV_Print.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                if (buttonText.Equals("生成条码") && (this.dGV_Print.Rows[e.RowIndex].DefaultCellStyle.BackColor != Color.Yellow))
                {
                    rTB_Barcode.Text = "";//清空richtextbox
                    AsmPlanObject apo = new AsmPlanObject();
                    string        plan_productionvr = dGV_Print.Rows[e.RowIndex].Cells["PRODUCTION_VR"].Value.ToString();
                    string        plan_data         = dGV_Print.Rows[e.RowIndex].Cells["DT"].Value.ToString();
                    string        plan_lineid       = dGV_Print.Rows[e.RowIndex].Cells["LINE_ID"].Value.ToString();
                    string        plan_number       = dGV_Print.Rows[e.RowIndex].Cells["NUMBER"].Value.ToString();
                    string        plan_productionid = dGV_Print.Rows[e.RowIndex].Cells["PRODUCTION_ID"].Value.ToString();
                    string        plan_id           = dGV_Print.Rows[e.RowIndex].Cells["ID"].Value.ToString();
                    apo.ID            = Convert.ToInt32(plan_id);
                    apo.NAME          = plan_productionvr;
                    apo.PRODUCTION_ID = Convert.ToInt32(plan_productionid);
                    apo.NUMBER        = Convert.ToInt32(plan_number);
                    apo.LINE_ID       = Convert.ToInt32(plan_lineid);

                    DateTime dt = Convert.ToDateTime(plan_data);
                    //int numofdate =Convert.ToInt32(dt.ToString("MM-dd"));
                    List <string> list = GetDayOfWeek(dt, plan_productionid);
                    CreateBarcodeBysomething(list, dt, apo);
                    ///设置R_PMS_PLAN_T打印标识
                    AsmPlan_BLL.SetBarcodeIdentification(plan_id);
                    MessageBox.Show("条码生成成功!");
                    Thread.Sleep(1000);
                    //dGV_Print.Rows[e.RowIndex]
                    dGV_Print.DataSource = null;
                    DataTable dtUpdate = AsmPlan_BLL.GetPlanObjectByConditionToPrint();
                    LoadSource(dtUpdate);
                }

                if (buttonText.Equals("展示条码") && (this.dGV_Print.Rows[e.RowIndex].DefaultCellStyle.BackColor == Color.Yellow))
                {
                    rTB_Barcode.Text = "";
                    DataTable dt = AsmPlanPrint_BLL.GetBarcodeByCondition(this.dGV_Print.Rows[e.RowIndex].Cells["ID"].Value.ToString());
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        rTB_Barcode.AppendText(dt.Rows[i]["SN"].ToString() + "\r");
                    }
                }
            }
        }
 /// <summary>
 /// 点击查询按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BT_Query_Click(object sender, EventArgs e)
 {
     try
     {
         string sql;                                                    //SQL搜索语句
         strCondition        = getCondition();                          //返回搜索条件语句
         sql                 = strCondition + " ORDER BY PPP.DT DESC "; //注意:RPP为运行时表(要更换)、“1”为开始,到时候要换成“4”
         planDt              = null;
         planDt              = AsmPlan_BLL.GetFinishPlansByCondition(sql);
         DGV_Plan.DataSource = planDt;                    //DataGridView数据流
         DGV_Plan.ClearSelection();
     }
     catch (Exception ex)
     {
         Log.InformationLog.Error("查询出错:" + ex.Message);
         MessageBoxEx.Show("查询出错:" + ex.Message);
     }
 }
Exemple #8
0
        // <summary>
        // 获取当前日期包含指定计划名且在指定日期范围内的SN
        // </summary>
        // <returns></returns>
        public List <string> GetDayOfWeek(DateTime dt, string id)
        {
            //DateTime startWeek1 = dt.AddDays(1 - Convert.ToInt32(dt.DayOfWeek.ToString("d")));  //本周周一
            //DateTime endWeek1 = startWeek1.AddDays(6);  //本周周日
            //int week = (int)dt.DayOfWeek;
            //if (week == 0) week = 7; //周日
            //DateTime startWeek = dt.AddDays(-(week - 1));
            //DateTime endWeek = startWeek.AddDays(6);
            #region
            int    str_month = Convert.ToInt32(dt.ToString("MM"));
            int    str_day = Convert.ToInt32(dt.ToString("dd"));
            string month = ""; string day = "";
            int    year = Convert.ToInt32(dt.ToString("yyyy"));
            for (int i = 1; i < 32; i++)
            {
                if (str_month == i)
                {
                    month = dic_month[i];
                }
                if (str_day == i)
                {
                    day = dic_month[i];
                }
            }
            string str_year = "";
            for (int i = 2017; i < 2051; i++)
            {
                if (i == year)
                {
                    str_year = dic_year[i];
                }
            }
            #endregion



            List <string> list = AsmPlan_BLL.GetSnByTime("'%" + str_year + month + day + "_______' " + " and  PRODUCTION_ID=' " + id + "'");
            return(list);
        }
Exemple #9
0
        /// <summary>
        /// 组合框事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox combox = sender as ComboBox;

            //这里比较重要
            //  combox.Leave += new EventHandler(combox_Leave);
            try
            {
                //在这里就可以做值是否改变判断
                if (combox.SelectedItem != null)
                {
                    //  ReflshDataGridView();
                    int row = DGV_Plan.SelectedRows[0].Index;
                    if (combox.SelectedValue.ToString() == "0")
                    {
                        MessageBox.Show("计划已开始或已经是初始化,不能再初始化!");
                        combox.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged);
                        ReflshDataGridView();
                        return;
                    }
                    else if (combox.SelectedValue.ToString() == "4" && Convert.ToInt32(planDt.Rows[row]["NUMBER"].ToString()) - Convert.ToInt32(planDt.Rows[row]["COMPLETE_NUMBER"].ToString()) > 0)
                    {
                        MessageBox.Show("计划没有完成,不能关闭计划!");
                        combox.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged);
                        ReflshDataGridView();
                        return;
                    }
                    else if (combox.SelectedValue.ToString() == "4" && Convert.ToInt32(planDt.Rows[row]["NUMBER"].ToString()) - Convert.ToInt32(planDt.Rows[row]["COMPLETE_NUMBER"].ToString()) == 0)
                    {
                        combox.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged);
                        #region >>>>>将运行时表中的数据转移到永久性表中
                        AsmPlanObject  apo  = AsmPlan_BLL.GetPlanObjectByCondition(" WHERE ID=" + Convert.ToInt32(planDt.Rows[row]["ID"].ToString()));
                        AsmPPlanObject appo = new AsmPPlanObject();
                        appo.DT                  = System.DateTime.Now;
                        appo.COMPLETE_FLAG       = "4";
                        appo.COMPLETE_NUMBER     = apo.COMPLETE_NUMBER;
                        appo.CREATE_BARCODE_FLAG = apo.CREATE_BARCODE_FLAG;
                        appo.LINE_ID             = apo.LINE_ID;
                        appo.NAME                = apo.NAME;
                        appo.NG_NUMBER           = apo.NG_NUMBER;
                        appo.NUMBER              = apo.NUMBER;
                        appo.OK_NUMBER           = apo.OK_NUMBER;
                        appo.OPREATION_USER      = apo.OPREATION_USER;
                        appo.PLAN_LEVEL          = apo.PLAN_LEVEL;
                        appo.PRODUCTION_ID       = apo.PRODUCTION_ID;
                        appo.REMAIND_NUMBER      = apo.REMAIND_NUMBER;
                        AsmPPlan_BLL.AddPPlan(appo);
                        AsmPlan_BLL.DeleteRPlanByCondition(" ID=" + apo.ID);
                        if (row < this.DGV_Plan.Rows.Count - 1)
                        {
                            for (int i = 0; i < this.DGV_Plan.Rows.Count - 1 - row; i++)
                            {
                                AsmPlanObject apoNext = AsmPlan_BLL.GetPlanObjectByCondition(" WHERE ID=" + Convert.ToInt32(planDt.Rows[row + i + 1]["ID"].ToString()));
                                apoNext.PLAN_LEVEL = apo.PLAN_LEVEL + i;
                                AsmPlan_BLL.UpdatePlan(apoNext);
                            }
                        }
                        #endregion
                        ReflshDataGridView();
                        return;
                    }
                    else if (combox.SelectedValue.ToString() == "3")
                    {
                        combox.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged);
                        #region >>>>>将运行表中的数据转移到永久性表中
                        AsmPlanObject  apo  = AsmPlan_BLL.GetPlanObjectByCondition(" WHERE ID=" + Convert.ToInt32(planDt.Rows[row]["ID"].ToString()));
                        AsmPPlanObject appo = new AsmPPlanObject();
                        appo.DT                  = System.DateTime.Now;
                        appo.COMPLETE_FLAG       = "3";
                        appo.COMPLETE_NUMBER     = apo.COMPLETE_NUMBER;
                        appo.CREATE_BARCODE_FLAG = apo.CREATE_BARCODE_FLAG;
                        appo.LINE_ID             = apo.LINE_ID;
                        appo.NAME                = apo.NAME;
                        appo.NG_NUMBER           = apo.NG_NUMBER;
                        appo.NUMBER              = apo.NUMBER;
                        appo.OK_NUMBER           = apo.OK_NUMBER;
                        appo.OPREATION_USER      = apo.OPREATION_USER;
                        appo.PLAN_LEVEL          = apo.PLAN_LEVEL;
                        appo.PRODUCTION_ID       = apo.PRODUCTION_ID;
                        appo.REMAIND_NUMBER      = apo.REMAIND_NUMBER;
                        AsmPPlan_BLL.AddPPlan(appo);
                        AsmPlan_BLL.DeleteRPlanByCondition(" ID=" + apo.ID);
                        if (row < this.DGV_Plan.Rows.Count - 1)
                        {
                            for (int i = 0; i < this.DGV_Plan.Rows.Count - 1 - row; i++)
                            {
                                AsmPlanObject apoNext = AsmPlan_BLL.GetPlanObjectByCondition(" WHERE ID=" + Convert.ToInt32(planDt.Rows[row + i + 1]["ID"].ToString()));
                                apoNext.PLAN_LEVEL = apo.PLAN_LEVEL + i;
                                AsmPlan_BLL.UpdatePlan(apoNext);
                            }
                        }
                        #endregion
                        ReflshDataGridView();
                        return;
                    }
                    else
                    {
                        AsmPlanObject apo = AsmPlan_BLL.GetPlanObjectByCondition(" WHERE ID=" + Convert.ToInt32(planDt.Rows[row]["ID"].ToString()));
                        apo.COMPLETE_FLAG = combox.SelectedValue.ToString();
                        AsmPlan_BLL.UpdatePlan(apo);
                        combox.SelectedIndexChanged -= new EventHandler(ComboBox_SelectedIndexChanged);
                        ReflshDataGridView();
                        //  DGV_Plan.ClearSelection();
                        //  DGV_Plan.Rows[row].Selected = true;
                        return;
                    }
                }

                // Thread.Sleep(100);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #10
0
        /// <summary>
        /// 按条件查询事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_select_Click(object sender, EventArgs e)
        {
            string str_name   = tB_name.Text.Trim();
            string str_lineid = "";

            if (lb_LINE_ID.SelectedValue != null)
            {
                str_lineid = lb_LINE_ID.SelectedValue.ToString();
            }
            else
            {
                str_lineid = "";
            }

            string str_operationuser = tb_operationuser.Text.Trim();
            string sql = "";

            if (str_name != null && str_name != "")
            {
                sql = "and C_ASM_PRODUCTION_T.PRODUCTION_VR='" + str_name + "'";
            }
            if (str_lineid != null && str_lineid != "")
            {
                if (sql != null)
                {
                    sql += " and " + " LINE_ID='" + str_lineid + "'";
                }
                else
                {
                    sql += "and LINE_ID='" + str_lineid + "'";
                }
            }
            if (str_operationuser != null && str_operationuser != "")
            {
                if (sql != "")
                {
                    sql += " and " + "OPREATION_USER='******'";
                }
                else
                {
                    sql += "and OPREATION_USER='******'";
                }
            }
            if (sql == "")
            {
                DataTable dt = AsmPlan_BLL.GetPlanObjectByInputConditionToPrint(sql);
                dGV_Print.DataSource = null;
                LoadSource(dt);
            }
            else
            {
                DataTable dt = AsmPlan_BLL.GetPlanObjectByInputConditionToPrint(sql);
                if (dt != null)
                {
                    dGV_Print.DataSource = null;
                    LoadSource(dt);
                }
                else
                {
                    MessageBox.Show("输入查询条件有误!");
                }
            }
        }