示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                DataTable dt = ExcelToDataTable(openFileDialog1.FileName, "s1", true);
                //for (int i = 0; i < dt.Rows.Count; i++)
                //{
                //    for (int j = 0; j < dt.Columns.Count; j++)
                //    {
                //        Console.WriteLine(dt.Rows[i][j].ToString());
                //    }
                //}
                Maticsoft.BLL.component comp_bll = new Maticsoft.BLL.component();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (!comp_bll.Exists(Convert.ToInt32(dt.Rows[i]["componentId"])))
                    {
                        Maticsoft.Model.component comp_mode = new Maticsoft.Model.component()
                        {
                            componentId = Convert.ToInt32(dt.Rows[i]["componentId"]),
                            ARef        = Convert.ToString(dt.Rows[i]["ARef"]),
                            jobnum      = Convert.ToString(dt.Rows[i]["jobnum"]),
                            name        = Convert.ToString(dt.Rows[i]["name"]),
                            size        = Convert.ToString(dt.Rows[i]["size"]),
                            photo       = Convert.ToString(dt.Rows[i]["photo"]),
                            sm          = Convert.ToString(dt.Rows[i]["sm"]),
                            remark      = Convert.ToString(dt.Rows[i]["remark"])
                        };
                        comp_bll.Add(comp_mode);
                    }
                }

                DataTable dt2 = ExcelToDataTable(openFileDialog1.FileName, "s2", true);
                Maticsoft.BLL.measures mea_bll = new Maticsoft.BLL.measures();
                for (int i = 0; i < dt2.Rows.Count; i++)
                {
                    if (!mea_bll.Exists(Convert.ToInt32(dt2.Rows[i]["id"])))
                    {
                        Maticsoft.Model.measures mea_obj = new Maticsoft.Model.measures()
                        {
                            id          = Convert.ToInt32(dt2.Rows[i]["id"]),
                            componentId = Convert.ToInt32(dt2.Rows[i]["componentId"]),
                            standardv   = Convert.ToString(dt2.Rows[i]["standardv"]),
                            step        = Convert.ToInt32(dt2.Rows[i]["step"]),
                            down        = Convert.ToString(dt2.Rows[i]["down"]),
                            up          = Convert.ToString(dt2.Rows[i]["up"]),
                            devicetype  = Convert.ToInt32(dt2.Rows[i]["devicetype"]),
                            position    = Convert.ToString(dt2.Rows[i]["position"]),
                            Tools       = Convert.ToString(dt2.Rows[i]["Tools"]),
                            CC          = Convert.ToString(dt2.Rows[i]["CC"]),
                        };
                        mea_bll.Add(mea_obj);
                    }
                }
            }
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox_name.Text == "")
                {
                    MessageBox.Show("名称不可以为空");
                    return;
                }

                if (textBox_bianhao.Text == "")
                {
                    MessageBox.Show("生产编号不可以为空");
                    return;
                }
                if (textBox_cc.Text == "")
                {
                    MessageBox.Show("尺寸不可以为空");
                    return;
                }
                if (textBox_sm.Text == "")
                {
                    MessageBox.Show("数模不可以为空");
                    return;
                }
                //if (textBox_picname.Text == "")
                //{
                //    MessageBox.Show("图片不可以为空");
                //    return;
                //}

                Maticsoft.BLL.component   com_bll   = new Maticsoft.BLL.component();
                Maticsoft.Model.component copm_mode = new Maticsoft.Model.component()
                {
                    name   = textBox_name.Text,
                    jobnum = textBox_gongdan.Text,
                    ARef   = textBox_bianhao.Text,
                    size   = textBox_cc.Text,
                    sm     = textBox_sm.Text,
                    photo  = textBox_picname.Text,
                    remark = "管理"
                };
                if (com_bll.Add(copm_mode))
                {
                    MessageBox.Show("新建成功");
                }
                else
                {
                    MessageBox.Show("新建失败");
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
            this.Close();
        }