示例#1
0
 private void allupdate()
 {
     for (int i = 0; i < dgv.Rows.Count; i++)
     {
         string to                    = dgv.Rows[i].Cells["Tools"].Value.ToString();
         string tl                    = dgv.Rows[i].Cells["position"].Value.ToString();
         string bz                    = dgv.Rows[i].Cells["standardv"].Value.ToString();
         string sg                    = dgv.Rows[i].Cells["up"].Value.ToString();
         string xg                    = dgv.Rows[i].Cells["down"].Value.ToString();
         string cun                   = dgv.Rows[i].Cells["CC"].Value.ToString();
         int    componentid           = Convert.ToInt32(dgv.Rows[i].Cells["componentid"].Value);
         int    XH                    = Convert.ToInt32(dgv.Rows[i].Cells["id"].Value);
         int    st                    = Convert.ToInt32(dgv.Rows[i].Cells["step"].Value);
         int    device_type           = Convert.ToInt32(dgv.Rows[i].Cells["devicetype"].Value == null ? "0" : dgv.Rows[i].Cells["devicetype"].Value);
         int    port_id               = Convert.ToInt32(dgv.Rows[i].Cells["portid"].Value);
         Maticsoft.BLL.measures   use = new Maticsoft.BLL.measures();
         Maticsoft.Model.measures us  = new measures()
         {
             id          = XH,
             step        = st,
             Tools       = to,
             position    = tl,
             standardv   = bz,
             up          = sg,
             down        = xg,
             componentId = componentid,
             CC          = cun,
             devicetype  = device_type,
             portid      = port_id,
         };
         use.Update(us);
     }
 }
        /// <summary>
        /// parsing algorithm from file to custom list named parsedRecordListbeforeDBinsert
        /// </summary>
        void parseFile()
        {

            if (filepaths.Count() > 0)
            {

                string line;
                try
                {
                    foreach (string file in filepaths)
                    {
                        StreamReader filestream = new StreamReader(file);

                        parsedlistfromfile = new List<measures>();
                        int startyear = 0;
                        int endyear = 0;
                        while ((line = filestream.ReadLine()) != null)
                        {

                            if (line.Contains(matchingYearstext))
                            {
                                int.TryParse(line.Substring(line.IndexOf(matchingYearstext) + matchingYearstext.Length, 4), out startyear);
                                int.TryParse(line.Substring(line.IndexOf(matchingYearstext) + matchingYearstext.Length + 4 + 1, 4), out endyear);

                            }
                            if (line.Contains(matchingXYtext))
                            {
                                var obj = new measures() { startyear = startyear, endyear = endyear };
                                int xValue = 0;
                                int yValue = 0;
                                var xytext = line.Substring(line.IndexOf(matchingXYtext) + matchingXYtext.Length).Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                int.TryParse(xytext[0], out xValue);
                                int.TryParse(xytext[1], out yValue);
                                obj.X = xValue;
                                obj.Y = yValue;

                                if (xValue > 0 && yValue > 0)
                                {
                                    int[,] xyValue = new int[12, 12];
                                    for (int i = 0; i < 12; i++)
                                    {
                                        line = filestream.ReadLine();
                                        if (line == null)
                                            break;
                                        var readingLine = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                        int j = 0;
                                        foreach (string s in readingLine)
                                        {
                                            int noval = 0;
                                            int.TryParse(s, out noval);
                                            xyValue[i, j++] = noval;
                                        }
                                    }
                                    obj.infomatrix = xyValue;
                                    parsedlistfromfile.Add(obj);
                                }
                            }
                        }

                        if (file != null)
                            filestream.Close();

                    }

                }
                catch (Exception ex)
                {

                }

            }
        }
示例#3
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mdf_bt_Click(object sender, EventArgs e)
        {
            //for (int i=0; i<dgv.Rows.Count;i++) {
            //bomname_tb.Text = dgv.Rows[0].Cells["tool"].Value.ToString();
            //gdno_tb.Text = dgv.Rows[0].Cells["testlocal"].Value.ToString();
            //scbh_tb.Text = dgv.Rows[0].Cells["bzz"].Value.ToString();
            //sandsm_tb.Text = dgv.Rows[0].Cells["sgc"].Value.ToString();
            //tm_tb.Text = dgv.Rows[0].Cells["xgc"].Value.ToString();
            //cicun_tb.Text = dgv.Rows[0].Cells["cicun"].Value.ToString();
            #region 判断条件


            if (gdno_tb.Text == "")
            {
                MessageBox.Show("请填写位置");
                return;
            }
            if (scbh_tb.Text == "")
            {
                MessageBox.Show("请填写标准值");
                return;
            }
            if (sandsm_tb.Text == "")
            {
                MessageBox.Show("请填上公差");
                return;
            }
            if (tm_tb.Text == "")
            {
                MessageBox.Show("请填下公差");
                return;
            }
            if (cicun_tb.Text == "")
            {
                MessageBox.Show("请填写尺寸");
                return;
            }
            if (comboBox_devs.Text == "")
            {
                MessageBox.Show("请选择工具");
                return;
            }

            #endregion
            int step_index = dgv.CurrentCell.RowIndex;
            int XH         = Convert.ToInt32(dgv.Rows[step_index].Cells["id"].Value);
            //String TO = bomname_tb.Text;
            string PO = gdno_tb.Text;
            string ST = scbh_tb.Text;
            string SG = sandsm_tb.Text;
            string XG = tm_tb.Text;
            string CI = cicun_tb.Text;
            // string LJH = textbox_ljh.Text;
            Maticsoft.BLL.measures   use = new Maticsoft.BLL.measures();
            Maticsoft.Model.measures us  = new measures()
            {
                id          = XH,
                Tools       = 1.ToString(),
                position    = PO,
                standardv   = ST,
                up          = SG,
                down        = XG,
                CC          = CI,
                componentId = Convert.ToInt32(this.LjHao),
                step        = Convert.ToInt32(dgv.Rows[step_index].Cells["step"].Value),
                //devicetype = this.td_lists[comboBox_devs.SelectedIndex].devicetype
                devicetype = port_list[comboBox_devs.SelectedIndex].devicetype,
                portid     = port_list[comboBox_devs.SelectedIndex].id,
            };
            use.Update(us);
            // }
            MessageBox.Show("修改成功");
            //Ctrol.Text = "";
            //bomname_tb.Text = "";
            gdno_tb.Text     = "";
            scbh_tb.Text     = "";
            sandsm_tb.Text   = "";
            tm_tb.Text       = "";
            cicun_tb.Text    = "";
            textbox_ljh.Text = "";
            Maticsoft.BLL.measures use1 = new Maticsoft.BLL.measures();
            string  aa = string.Format("componentId = '{0}'ORDER BY step", LjHao);
            DataSet ds = use1.GetListByPage3(aa, "", 0, 100);
            dgv.DataSource = ds.Tables[0];
            foreach (DataGridViewRow row in dgv.Rows)
            {
                row.Cells["step"].Value = row.Index + 1;
            }


            // 选中下一行
            dgv.ClearSelection();
            step_index += 1;
            int last_line = dgv.Rows.Count;
            if (step_index >= last_line - 1)
            {
                step_index = last_line - 1;
            }

            dgv.Rows[step_index].Selected          = true;
            dgv.Rows[step_index].Cells[0].Selected = true;
            dgv.CurrentCell = dgv.Rows[step_index].Cells["step"];
        }
示例#4
0
        /// <summary>
        ///
        /// 新建规矩
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void new_bt_Click(object sender, EventArgs e)
        {
            try
            {
                #region 判断条件

                if (gdno_tb.Text == "")
                {
                    MessageBox.Show("请填写位置");
                    return;
                }
                if (scbh_tb.Text == "")
                {
                    MessageBox.Show("请填写标准值");
                    return;
                }
                if (sandsm_tb.Text == "")
                {
                    MessageBox.Show("请填上公差");
                    return;
                }
                if (tm_tb.Text == "")
                {
                    MessageBox.Show("请填下公差");
                    return;
                }
                if (cicun_tb.Text == "")
                {
                    MessageBox.Show("请填写尺寸");
                    return;
                }
                if (comboBox_devs.Text == "")
                {
                    MessageBox.Show("请选择工具");
                    return;
                }
                else
                {
                    int index = comboBox_devs.SelectedIndex;
                }
                #endregion
                int max_step = dgv.Rows.Count;

                Maticsoft.BLL.measures   use = new Maticsoft.BLL.measures();
                Maticsoft.Model.measures us  = new measures()
                {
                    // step=Convert.ToInt32( bz.Text),
                    // S Tools = bomname_tb.Text,
                    position    = gdno_tb.Text,
                    standardv   = scbh_tb.Text,
                    up          = sandsm_tb.Text,
                    down        = tm_tb.Text,
                    CC          = cicun_tb.Text,
                    componentId = Convert.ToInt32(this.LjHao),
                    devicetype  = port_list[comboBox_devs.SelectedIndex].devicetype,
                    portid      = port_list[comboBox_devs.SelectedIndex].id,
                    step        = max_step + 1,
                    Tools       = comboBox_devs.Text,
                };
                // MessageBox.Show(this.comboBox_devs.SelectedIndex.ToString());
                use.Add(us);
                MessageBox.Show("已经提交保存");
                gdno_tb.Text   = "";
                scbh_tb.Text   = "";
                sandsm_tb.Text = "";
                tm_tb.Text     = "";
                cicun_tb.Text  = "";
                this.initdgv();
            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
            }
        }