private void button1_Click(object sender, EventArgs e) { string componentId = dataGridView1.CurrentRow.Cells["componentId"].Value.ToString(); Maticsoft.BLL.component comp_bll = new Maticsoft.BLL.component(); DataSet ds = comp_bll.GetList(string.Format(" componentId = '{0}'", componentId)); DataTable dt = ds.Tables[0]; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { string fName = saveFileDialog1.FileName; //this.DataToExcel(dt, fName); Maticsoft.BLL.measures mea_bll = new Maticsoft.BLL.measures(); DataSet ds2 = mea_bll.GetList(string.Format(" componentId = '{0}'", componentId)); DataTable dt2 = ds2.Tables[0]; for (int i = 0; i < dt2.Rows.Count; i++) { for (int j = 0; j < dt2.Columns.Count; j++) { Console.WriteLine(dt2.Rows[i][j].ToString()); } } this.TableToExcelForXLSX2003(dt, dt2, fName, "s1"); // this.TableToExcelForXLSX2003(dt2, fName, "s2"); //string file_name = Path.GetFileNameWithoutExtension(fName) + "详情"+ Path.GetExtension(fName); //file_name = Path.GetDirectoryName(fName)+ "\\" + file_name; //this.DataToExcel(dt2, file_name); //this.TableToExcelForXLSX2003(dt2, file_name, "s2"); } }
public void dealwithcomp(object lingjianhao) { string lj_num = lingjianhao.ToString(); // 目前架构这样, 就不用联合查询了。 宁可多查询一部 #region 获得零件id Maticsoft.BLL.parts parts_bll = new Maticsoft.BLL.parts(); List <Maticsoft.Model.parts> parts_objs = parts_bll.GetModelList(string.Format(" PN = {0} ", lj_num)); if (parts_objs.Count == 1) { Maticsoft.Model.parts part_obj = parts_objs[0]; this.comp_type = Convert.ToInt32(part_obj.componentId); } else { System.Windows.Forms.MessageBox.Show("未知零件类型"); this.Close(); } #endregion #region 获得零件名字 Maticsoft.BLL.component comp_bll = new Maticsoft.BLL.component(); Maticsoft.Model.component comp_mode = comp_bll.GetModel(comp_type); if (comp_mode != null) { this.comp_name = comp_mode.name; this.mode = comp_mode.sm; } // System.Windows.Forms.MessageBox.Show(string.Format("comp_type : == {0}, comp_name : === {1}", this.comp_type, this.comp_name)); #endregion }
private void AddAutoComp() { Task <List <Maticsoft.Model.component> > ff_task = new Task <List <Maticsoft.Model.component> >(() => { List <Maticsoft.Model.component> ret_list = new List <Maticsoft.Model.component>(); Maticsoft.BLL.component part_bll = new Maticsoft.BLL.component(); ret_list = part_bll.GetModelList(" "); return(ret_list); }); ff_task.ContinueWith((ret_list) => { var datasou = new AutoCompleteStringCollection(); List <Maticsoft.Model.component> local_ret_list = ret_list.Result; //ret_list.ConvertAll(); List <string> pn_list = local_ret_list.ConvertAll <string>((temp_obj) => { return(temp_obj.componentId.ToString()); }); datasou.AddRange(pn_list.ToArray()); textBox_ljhao.BeginInvoke(new Action(() => { textBox_ljhao.AutoCompleteCustomSource = datasou; textBox_ljhao.AutoCompleteMode = AutoCompleteMode.SuggestAppend; textBox_ljhao.AutoCompleteSource = AutoCompleteSource.CustomSource; })); }); ff_task.Start(); }
private void dgvljjl_CellClick(object sender, DataGridViewCellEventArgs e) { //MessageBox.Show(e.ColumnIndex.ToString()); this.tabControl_main.SelectedIndex = 1; if (e.RowIndex >= 0 && e.RowIndex < dgvljjl.Rows.Count && e.ColumnIndex >= 0 && e.ColumnIndex < dgvljjl.Columns.Count) { // MessageBox.Show(dgvljjl.Columns.Count.ToString() + " "+ e.ColumnIndex); if (dgvljjl.Columns[e.ColumnIndex].HeaderText == "零件类型基础管理") { addparts addp = new addparts(); string ljh = dgvljjl.Rows[e.RowIndex].Cells["PN"].Value.ToString(); string Barcode = dgvljjl.Rows[e.RowIndex].Cells["Barcode"].Value.ToString(); addp.setenableSetValue(ljh, Barcode); addp.ShowDialog(); return; MessageBox.Show("设置位置"); } string id = dgvljjl.Rows[e.RowIndex].Cells["component"].Value.ToString(); this.textBox_query.Text = id; string where_str = ""; // 通过零件的id或者零件的名字 where_str += string.Format(" componentId= '{0}' ", this.textBox_query.Text); Maticsoft.BLL.component com_bll = new Maticsoft.BLL.component(); DataSet ds = com_bll.GetListByPage2(where_str, "", cur_step, cur_step + cur_page_lenb); DataTable dt = ds.Tables[0]; this.dataGridView1.DataSource = dt; } else { // MessageBox.Show("选中了无效的行"); } }
private void button_del_Click(object sender, EventArgs e) { //dataGridView1.SelectedRows foreach (DataGridViewRow dr in dataGridView1.SelectedRows) { int will_del_id = Convert.ToInt32(dr.Cells["componentId"].Value); del_list.Add(will_del_id); dataGridView1.Rows.Remove(dr); } return; int index = this.dataGridView1.CurrentCell.RowIndex; if (index >= 0 && index < this.dgvljjl.Rows.Count) { var id = this.dataGridView1.Rows[index].Cells["componentId"].Value; Maticsoft.BLL.component comp_bll = new Maticsoft.BLL.component(); if (comp_bll.Delete(Convert.ToInt32(id))) { MessageBox.Show("删除成功"); } else { MessageBox.Show("没有删除成功"); } } requery(); }
private void requery() { string where_str = " 1=1 "; if (this.textBox_query.Text != "") { // 通过零件的id或者零件的名字 where_str += string.Format(" and ( componentId like '%{0}%' or name like '%{1}%') ", this.textBox_query.Text, this.textBox_query.Text); } Maticsoft.BLL.component parts_bll = new Maticsoft.BLL.component(); totle_num = parts_bll.GetRecordCount(where_str); if (this.totle_num % this.cur_page_lenb == 0) { this.totle_page_num = this.totle_num / this.cur_page_lenb; } else { this.totle_page_num = this.totle_num / this.cur_page_lenb + 1; } string page_info = string.Format("{0}/{1}", 1, totle_page_num); this.label_tot.Text = page_info; this.init_dgv(); }
/// <summary> /// /// 初始化整个表格 /// </summary> private void initdgv() { this.del_list.Clear(); Maticsoft.BLL.measures use1 = new Maticsoft.BLL.measures(); string aa = string.Format("componentId = '{0}'ORDER BY step", LjHao);//ORDER BY step 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; } Maticsoft.BLL.component mea_bll = new Maticsoft.BLL.component(); Maticsoft.Model.component comp_mode = mea_bll.GetModel(Convert.ToInt32(LjHao)); if (comp_mode != null) { Task a_task = new Task(new Action(() => { Thread.Sleep(1000); renderView.Invoke(new Action(() => { string base_dir = Environment.CurrentDirectory; base_dir += "\\shumo\\"; base_dir += comp_mode.sm; IgesReader reader = new IgesReader(); bool ret = reader.Read(base_dir, new CadView(this.renderView)); Console.WriteLine("ret ====== " + ret); renderView.FitAll(); renderView.RequestDraw(); })); })); a_task.Start(); } }
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); } } } }
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(); }
private void addparts_Load(object sender, EventArgs e) { Maticsoft.BLL.component component_bll = new Maticsoft.BLL.component(); comp_list = component_bll.GetModelList(""); if (comp_list.Count > 0) { List <string> com_strlist = comp_list.ConvertAll <string>(x => x.componentId.ToString()); this.comboBox1.Items.AddRange(com_strlist.ToArray()); } }
public void dealwithcomp(int type) { comp_type = type; #region 获得零件名字 Maticsoft.BLL.component comp_bll = new Maticsoft.BLL.component(); Maticsoft.Model.component comp_mode = comp_bll.GetModel(type); if (comp_mode != null) { this.comp_name = comp_mode.name; this.mode = comp_mode.sm; } // System.Windows.Forms.MessageBox.Show(string.Format("comp_type : == {0}, comp_name : === {1}", this.comp_type, this.comp_name)); #endregion }
private void init_dgv() { del_list_for_part.Clear(); #region 获得查询语句 string where_str = " 1=1 "; if (this.textBox_query.Text != "") { // 通过零件的id或者零件的名字 where_str += string.Format(" and ( componentId like '%{0}%' or name like '%{1}%') ", this.textBox_query.Text, this.textBox_query.Text); } Maticsoft.BLL.component com_bll = new Maticsoft.BLL.component(); DataSet ds = com_bll.GetListByPage2(where_str, "", cur_page_lenb * cur_page_num, cur_page_lenb * (1 + cur_page_num)); DataTable dt = ds.Tables[0]; this.dataGridView1.DataSource = dt; #endregion }
private void bt_update_Click(object sender, EventArgs e) { Maticsoft.BLL.component comp_bll = new Maticsoft.BLL.component(); foreach (DataGridViewRow dgr in dataGridView1.Rows) { if (dgr != null) { Maticsoft.Model.component comp_mode = new Maticsoft.Model.component { ARef = dgr.Cells["ARef"].Value.ToString(), componentId = Convert.ToInt32(dgr.Cells["componentId"].Value), jobnum = dgr.Cells["jobnum"].Value.ToString(), size = dgr.Cells["size"].Value.ToString(), name = dgr.Cells["name"].Value.ToString(), photo = dgr.Cells["photo"].Value.ToString(), remark = dgr.Cells["remark"].Value.ToString(), sm = dgr.Cells["sm"].Value.ToString(), }; if (comp_bll.Update(comp_mode)) { // MessageBox.Show("更新成功"); } else { MessageBox.Show("更新失败"); } } } foreach (int del_id in del_list) { if (comp_bll.Delete(del_id)) { // MessageBox.Show("删除成功"); } else { MessageBox.Show("没有删除成功"); } } MessageBox.Show("提交成功"); // DataGridViewRow dgr = dataGridView1.CurrentRow }
private void DevSt_Load(object sender, EventArgs e) { this.get_lingjian(); //where 1 = 1 GROUP BY pn LIMIT 10 //global.CurActive = "DevSt"; //this.TopMost = true; //this.Activate(); this.last_flp.Controls.Clear(); //Maticsoft.BLL.test test_bll = new Maticsoft.BLL.test(); //List<Maticsoft.Model.test> test_lists = test_bll.GetModelList(" 1=1 GROUP BY pn LIMIT 10"); Maticsoft.BLL.component com_bll = new Maticsoft.BLL.component(); List <Maticsoft.Model.component> com_list = com_bll.GetModelList(""); foreach (var test_obj in com_list) { Button a = new Button(); a.Text = test_obj.name.ToString(); a.Tag = test_obj.componentId.ToString(); a.Click += new System.EventHandler(this.button_Click); this.last_flp.Controls.Add(a); } }
private void BomFrom2_Load(object sender, EventArgs e) { string where_str = " 1=1 "; if (this.textBoxljjl_query.Text != "") { where_str += string.Format(" and ( componentId = {0}' or Barcode ARef '%{1}%') ", this.textBoxljjl_query.Text, this.textBoxljjl_query.Text); } Maticsoft.BLL.component parts_bll = new Maticsoft.BLL.component(); totle_num = parts_bll.GetRecordCount(where_str); if (this.totle_num % this.cur_page_lenb == 0) { this.totle_page_num = this.totle_num / this.cur_page_lenb; } else { this.totle_page_num = this.totle_num / this.cur_page_lenb + 1; } string page_info = string.Format("{0}/{1}", 1, totle_page_num); this.label_tot.Text = page_info; this.init_dgv(); }