private void but_incycle_Click(object sender, EventArgs e)
        {
            //存储你要修改的数据
            DataTable dtselect = new DataTable();

            //为datatable添加你需要添加的数据的字段名称
            dtselect.Columns.Add(new DataColumn("id"));
            dtselect.Columns.Add(new DataColumn("bar_code"));
            dtselect.Columns.Add(new DataColumn("ca_name"));
            dtselect.Columns.Add(new DataColumn("in_cycle"));
            DataRow dr = dtselect.NewRow();

            //int position = 0;//插入数据的位置
            //在循环中判断,取得你需要修改的数据
            for (int i = 0; i < dgv_01.Rows.Count; i++)
            {
                if ((bool)dgv_01.Rows[i].Cells["isselect"].Value == true)
                {
                    // InsertAt  InsertAt

                    dr["id"]       = dgv_01.Rows[i].Cells["id"].Value.ToString();
                    dr["bar_code"] = dgv_01.Rows[i].Cells["bar_code"].Value;
                    dr["ca_name"]  = dgv_01.Rows[i].Cells["ca_name"].Value.ToString();
                    //循环时,检测当前实体包是否在循环中
                    if (dgv_01.Rows[i].Cells["in_cycle"].Value.ToString() == "否")
                    {
                        dr["in_cycle"] = dgv_01.Rows[i].Cells["in_cycle"].Value.ToString();
                    }
                    else
                    {
                        MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("putcycle", EnumPromptMessage.warning, new string[] { "存在" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    //给datatable添加一行数据
                    //dtselect.Rows.InsertAt(dr, position);
                    dtselect.Rows.Add(dr.ItemArray);
                    //position++;
                }
            }
            //如果行数为0,则说明没有选择实体包
            if (dtselect.Rows.Count == 0)
            {
                MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("choiceset", EnumPromptMessage.warning), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            HCSCM_in_cycle_location hcsm = new HCSCM_in_cycle_location(newold_type, dtselect);

            // HCSCM_set_cycle_location hcsm = new HCSCM_set_cycle_location(dtselect, newold_type);
            //获取一个值,指是否在Windows任务栏中显示窗体。
            hcsm.ShowInTaskbar = false;
            hcsm.ShowDialog();
            Loaddata(newold_type);
            cb_old.Checked = false;
            cb_new.Checked = false;
        }
Esempio n. 2
0
        private void but_ok_Click(object sender, EventArgs e)
        {
            //判断是进循环还是出循环,if_incycle == false为进循环
            if (if_incycle == false)
            {
                bool type = true;//新旧包类型,true为新包
                //cb_set为空时,tb_set为判断条件
                if (this.cb_set.Text == "")
                {
                    if (this.tb_set.Text == "新包")
                    {
                        type = true;
                    }
                    else
                    {
                        type = false;
                    }
                }
                //tb_set为空时,cb_set为判断条件
                if (this.tb_set.Text == "")
                {
                    if (this.cb_set.Text == "新包")
                    {
                        type = true;
                    }
                    else
                    {
                        type = false;
                    }
                    if (this.cb_set.SelectedItem == null)
                    {
                        MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("filltype", EnumPromptMessage.warning, new string[] { "新旧包" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
                //存储你要修改的数据
                DataTable dtselect = new DataTable();
                //为datatable添加你需要添加的数据的字段名称
                dtselect.Columns.Add(new DataColumn("id"));
                dtselect.Columns.Add(new DataColumn("bar_code"));
                dtselect.Columns.Add(new DataColumn("ca_name"));
                dtselect.Columns.Add(new DataColumn("in_cycle"));
                DataRow dr = dtselect.NewRow();
                //在循环中判断,取得你需要修改的数据
                for (int i = 0; i < dgv_01.Rows.Count; i++)
                {
                    if ((bool)dgv_01.Rows[i].Cells["isselect"].Value == true)
                    {
                        dr["id"]       = dgv_01.Rows[i].Cells["id"].Value.ToString();
                        dr["bar_code"] = dgv_01.Rows[i].Cells["bar_code"].Value;
                        dr["ca_name"]  = dgv_01.Rows[i].Cells["ca_name"].Value.ToString();
                        //dr["in_cycle"] = dgv_01.Rows[i].Cells["in_cycle"].Value.ToString();
                        //循环时,检测当前实体包是否在循环中
                        //if (dgv_01.Rows[i].Cells["in_cycle"].Value.ToString() == "否")
                        //{
                        //    dr["in_cycle"] = dgv_01.Rows[i].Cells["in_cycle"].Value.ToString();
                        //}
                        //else
                        //{
                        //    MessageBox.Show("你选择的实体包中存在循环中的实体包,请重新选择。", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //    return;
                        //}

                        //给datatable添加一行数据
                        dtselect.Rows.Add(dr.ItemArray);
                    }
                }
                //如果行数为0,则说明没有选择实体包
                if (dtselect.Rows.Count == 0)
                {
                    MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("choiceset", EnumPromptMessage.warning), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                HCSCM_in_cycle_location hcsm = new HCSCM_in_cycle_location(type, dtselect);
                // HCSCM_set_cycle_location hcsm = new HCSCM_set_cycle_location(dtselect, newold_type);
                //获取一个值,指是否在Windows任务栏中显示窗体。
                hcsm.ShowInTaskbar = false;
                hcsm.ShowDialog();
                this.Close();
            }
            else
            {
                if (dgv_01 != null)
                {
                    int slect   = 0; //用于判断有没有选择实体包
                    int success = 0; //用于判断添加是否添加成功
                    //判断是否存在已经不在循环里的包
                    for (int i = 0; i < dgv_01.Rows.Count; i++)
                    {
                        //为false的代表是不打勾的,不需移出循环
                        if ((bool)dgv_01.Rows[i].Cells["isselect"].Value == false)
                        {
                            slect++;//每存在一个不打勾的实体包加1
                            continue;
                        }
                    }
                    //如果相等说明没有选择实体包
                    if (slect == dgv_01.Rows.Count)
                    {
                        MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("choiceset", EnumPromptMessage.warning), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    slect = 0;//清零
                    //datatable几行就循环几次,在工单中为每一个旧的打勾的实体包修改记录
                    for (int i = 0; i < dgv_01.Rows.Count; i++)
                    {
                        //为false的代表是不打勾的,不需移出循环
                        if ((bool)dgv_01.Rows[i].Cells["isselect"].Value == false)
                        {
                            slect++;//每存在一个不打勾的实体包加1
                            continue;
                        }
                        //开始出循环
                        CnasRemotCall reCnasRemotCall = new CnasRemotCall();
                        SortedList    sttemp01        = new SortedList();
                        sttemp01.Add(1, dgv_01.Rows[i].Cells["id"].Value.ToString());
                        string    sql   = reCnasRemotCall.RemotInterface.CheckSelectData("HCS-workset-sec006", sttemp01);
                        DataTable getdt = reCnasRemotCall.RemotInterface.SelectData("HCS-workset-sec006", sttemp01);//查出旧实体包原来的动作
                        if (getdt == null)
                        {
                            return;
                        }
                        #region 出循环时,改工单和包的状态
                        SortedList sltmp   = new SortedList();
                        SortedList sltmp01 = new SortedList();
                        sltmp01.Add(1, 9);
                        sltmp01.Add(2, dgv_01.Rows[i].Cells["id"].Value.ToString());
                        sltmp01.Add(3, 6);
                        sltmp01.Add(4, dgv_01.Rows[i].Cells["id"].Value.ToString());
                        sltmp01.Add(5, getdt.Rows[0]["wf_code"].ToString());
                        sltmp.Add(1, sltmp01);
                        // string testSQL = reCnasRemotCall.RemotInterface.CheckUPData(1, "HCS-worksetupcycle-up001", sltmp, null);
                        int recint = reCnasRemotCall.RemotInterface.UPData(1, "HCS-worksetupcycle-up001", sltmp, null);
                        if (recint > -1)
                        {
                            success++;
                        }
                        #endregion
                    }

                    //如果需要添加的数量等于添加成功的数量,则移出成功
                    if (dgv_01.Rows.Count - slect == success)
                    {
                        MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("successful", EnumPromptMessage.warning, new string[] { "实体包已经移出循环" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("errorloop", EnumPromptMessage.error, new string[] { "移出" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    this.Close();
                }
            }
        }