private void init_ljjldgv() { this.del_list.Clear(); #region 获得查询语句 string where_str = " 1=1 "; if (this.textBoxljjl_query.Text != "") { where_str += string.Format(" and ( PN like '%{0}%' or Barcode like '%{1}%') ", this.textBoxljjl_query.Text, this.textBoxljjl_query.Text); } if (this.textBox_type.Text != "") { where_str += string.Format(" and T.componentId = {0} ", this.textBox_type.Text); } Maticsoft.BLL.parts parts_bll = new Maticsoft.BLL.parts(); DataSet ds = parts_bll.GetListByPage2(where_str, "", cur_page_lenb * cur_page_num2, cur_page_lenb * (1 + cur_page_num2)); DataTable dt = ds.Tables[0]; //if (this.textBox_type.Text != "") //{ // DataTable dtNew = dt.Clone(); // where_str += string.Format(" and {0}", textBox_type.Text); // DataRow[] drArr = dt.Select(string.Format(" componentId = {0}", this.textBox_type.Text)); // for (int i = 0; i < drArr.Length; i++) // { // dtNew.ImportRow(drArr[i]); // } // this.dgvljjl.DataSource = dtNew; // return; //} this.dgvljjl.DataSource = dt; #endregion }
private void buttonX1_Click(object sender, EventArgs e) { //TestBZFrom tbz = new TestBZFrom(); //tbz.Show(); for (int i = 0; i < gridView1.RowCount; i++) { int XH = Convert.ToInt32(gridView1.GetRowCellValue(i, "id")); string LJH = gridView1.GetRowCellValue(i, "PN").ToString(); string NM = gridView1.GetRowCellValue(i, "name").ToString(); string GDH = gridView1.GetRowCellValue(i, "jobnum").ToString(); string CSBH = gridView1.GetRowCellValue(i, "ARef").ToString(); string CC = gridView1.GetRowCellValue(i, "size").ToString(); string sd = gridView1.GetRowCellValue(i, "sm").ToString(); string TM = gridView1.GetRowCellValue(i, "Barcode").ToString(); Maticsoft.BLL.parts use = new Maticsoft.BLL.parts(); Maticsoft.Model.parts us = new parts() { id = XH, PN = LJH, //name = NM, //jobnum = GDH, //ARef = CSBH, //size = CC, //sm = sd, Barcode = TM, }; use.Update(us); } MessageBox.Show("修改成功"); }
private void buttonlj_del_Click(object sender, EventArgs e) { foreach (DataGridViewRow dr in dgvljjl.SelectedRows) { int will_del_id = Convert.ToInt32(dr.Cells["id"].Value); del_list_for_part.Add(will_del_id); dgvljjl.Rows.Remove(dr); } return; // 获得选中行 int index = this.dgvljjl.CurrentCell.RowIndex; if (index >= 0 && index < this.dgvljjl.Rows.Count) { var id = this.dgvljjl.Rows[index].Cells["id"].Value; Maticsoft.BLL.parts parts_bll = new Maticsoft.BLL.parts(); if (parts_bll.Delete(Convert.ToInt32(id))) { MessageBox.Show("删除成功"); } else { MessageBox.Show("未删除成功"); } } requery2(); }
private void requery2() { string where_str = " 1=1 "; if (this.textBoxljjl_query.Text != "") { where_str += string.Format(" and ( PN like '%{0}%' or Barcode like '%{1}%') ", this.textBoxljjl_query.Text, this.textBoxljjl_query.Text); } if (this.textBox_type.Text != "") { where_str += string.Format(" and componentId = {0} ", this.textBox_type.Text); } Maticsoft.BLL.parts parts_bll = new Maticsoft.BLL.parts(); totle_num2 = parts_bll.GetRecordCount(where_str); if (this.totle_num2 % this.cur_page_lenb == 0) { this.totle_page_num2 = this.totle_num2 / this.cur_page_lenb; } else { this.totle_page_num2 = this.totle_num2 / this.cur_page_lenb + 1; } //int tot_page_index = this.totle_num / this.cur_page_lenb + (this.totle_num % this.cur_page_lenb == 0 ? 0 : 1); string page_info = string.Format("{0}/{1}", 1, totle_page_num2); this.label_baifen1.Text = page_info; init_ljjldgv(); }
private void BomFrom_Load(object sender, EventArgs e) { Maticsoft.BLL.parts part_bll = new Maticsoft.BLL.parts(); string where_string = this.query_wherestring(); this.totle_num = part_bll.GetRecordCount(where_string); string parem_num = string.Format("1/{0}", this.totle_num / this.cur_page_lenb + 1); labelX1.Text = parem_num; // Maticsoft.BLL.parts pr = new Maticsoft.BLL.parts(); DataSet ds = part_bll.GetList(" 1=1 limit 30 "); main_gc.DataSource = ds.Tables[0]; //DataTable dt = new DataTable();//创建表 //dt.Columns.Add("ljh", typeof(String)); //dt.Columns.Add("mc", typeof(String)); //dt.Columns.Add("gdh", typeof(String)); //dt.Columns.Add("scbh", typeof(String)); //dt.Columns.Add("cc", typeof(String)); //dt.Columns.Add("sandsm", typeof(String)); //dt.Columns.Add("tm", typeof(String)); //dt.Columns.Add("clbz", typeof(String)); //dt.Columns.Add("clsj", typeof(String)); //dt.Rows.Add(new object[] { "00001", "XX零件", "123223", "312312", "1*2*3","xxx.step" ,"3213123131231"});//添加行 //dt.Rows.Add(new object[] { "00002", "XX零件", "423523", "321122", "2*2*1", "xxx.step", "3213123131232" }); //dt.Rows.Add(new object[] { "00003", "XX零件", "242123", "441212", "2*3*3", "xxx.step", "3213123131233" }); //this.main_gc.DataSource = dt; }
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 }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtPN.Text.Trim().Length == 0) { strErr += "PN不能为空!\\n"; } if (this.txtname.Text.Trim().Length == 0) { strErr += "name不能为空!\\n"; } if (this.txtjobnum.Text.Trim().Length == 0) { strErr += "jobnum不能为空!\\n"; } if (this.txtARef.Text.Trim().Length == 0) { strErr += "ARef不能为空!\\n"; } if (this.txtsize.Text.Trim().Length == 0) { strErr += "size不能为空!\\n"; } if (this.txtsm.Text.Trim().Length == 0) { strErr += "sm不能为空!\\n"; } if (this.txtBarcode.Text.Trim().Length == 0) { strErr += "Barcode不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string PN = this.txtPN.Text; string name = this.txtname.Text; string jobnum = this.txtjobnum.Text; string ARef = this.txtARef.Text; string size = this.txtsize.Text; string sm = this.txtsm.Text; string Barcode = this.txtBarcode.Text; Maticsoft.Model.parts model = new Maticsoft.Model.parts(); model.PN = PN; model.name = name; model.jobnum = jobnum; model.ARef = ARef; model.size = size; model.sm = sm; model.Barcode = Barcode; Maticsoft.BLL.parts bll = new Maticsoft.BLL.parts(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
private void ShowInfo(int id) { Maticsoft.BLL.parts bll = new Maticsoft.BLL.parts(); Maticsoft.Model.parts model = bll.GetModel(id); this.lblid.Text = model.id.ToString(); this.txtPN.Text = model.PN; this.txtname.Text = model.name; this.txtjobnum.Text = model.jobnum; this.txtARef.Text = model.ARef; this.txtsize.Text = model.size; this.txtsm.Text = model.sm; this.txtBarcode.Text = model.Barcode; }
private void del_bt_Click(object sender, EventArgs e) { DataRow DR = gridView1.GetDataRow(gridView1.FocusedRowHandle); Maticsoft.BLL.parts use = new Maticsoft.BLL.parts(); use.Delete(Convert.ToInt32(DR["id"])); //MessageBox.Show(a["id"].ToString()); MessageBox.Show("删除成功"); Maticsoft.BLL.parts usec = new Maticsoft.BLL.parts(); DataSet ds = usec.GetAllList(); main_gc.DataSource = ds.Tables[0]; }
private void reQuery() { string where_string = this.query_wherestring(); // 查询出来test 数据 Maticsoft.BLL.parts part_bll = new Maticsoft.BLL.parts(); // List<Maticsoft.Model.test> test_lists = test_bll.GetModelList(where_str); DataSet ds = part_bll.GetListByPage(where_string, "", cur_step + 1, cur_step + cur_page_lenb); System.Data.DataTable dt = ds.Tables[0]; // System.Data.DataTable dest_table = .DataSource as System.Data.DataTable; main_gc.DataSource = dt; }
private void button3_Click(object sender, EventArgs e) { Maticsoft.BLL.parts comp_bll = new Maticsoft.BLL.parts(); foreach (int del_id in del_list_for_part) { if (comp_bll.Delete(del_id)) { // MessageBox.Show("删除成功"); } else { MessageBox.Show("没有删除成功"); } } MessageBox.Show("提交成功"); }
private void get_lingjian() { Task query_task = new Task(() => { Maticsoft.BLL.parts parts_list = new Maticsoft.BLL.parts(); List <Maticsoft.Model.parts> pa_list = parts_list.GetModelList(" 1=1 GROUP BY pn"); var datasou = new AutoCompleteStringCollection(); List <string> pn_list = pa_list.ConvertAll <string>((temp_obj) => { return(temp_obj.PN); }); datasou.AddRange(pn_list.ToArray()); textBoxX1.Invoke(new Action(() => { textBoxX1.AutoCompleteCustomSource = datasou; textBoxX1.AutoCompleteMode = AutoCompleteMode.SuggestAppend; textBoxX1.AutoCompleteSource = AutoCompleteSource.CustomSource; })); }); query_task.Start(); }
private void test_bt_Click(object sender, EventArgs e) { if (textBoxX1.Text == "") { MessageBox.Show("请输入零件号"); return; } // 获得类型 //Program.txtbh = textBoxX1.Text; Maticsoft.BLL.parts parts_bll = new Maticsoft.BLL.parts(); List <Maticsoft.Model.parts> parts_mode = parts_bll.GetModelList(string.Format(" PN='{0}' ", textBoxX1.Text)); if (parts_mode.Count <= 0) { return; } Program.type = Convert.ToInt32(parts_mode[0].componentId); StepTestFrom stf = new StepTestFrom(); stf.CompId = textBoxX1.Text; stf.ShowDialog(); }
private void tabControl_main_SelectedIndexChanged(object sender, EventArgs e) { if (tabControl_main.SelectedIndex == 0) { // MessageBox.Show("导入零件类型数据"); this.init_dgv(); } else if (tabControl_main.SelectedIndex == 1) { string where_str = " 1=1 "; if (this.textBoxljjl_query.Text != "") { where_str += string.Format(" and ( PN like '%{0}%' or Barcode like '%{1}%') ", this.textBoxljjl_query.Text, this.textBoxljjl_query.Text); } if (this.textBox_type.Text != "") { where_str += string.Format(" and componentId = {0} ", this.textBox_type.Text); } Maticsoft.BLL.parts parts_bll = new Maticsoft.BLL.parts(); totle_num2 = parts_bll.GetRecordCount(where_str); if (this.totle_num2 % this.cur_page_lenb == 0) { this.totle_page_num2 = this.totle_num2 / this.cur_page_lenb; } else { this.totle_page_num2 = this.totle_num2 / this.cur_page_lenb + 1; } //int tot_page_index = this.totle_num / this.cur_page_lenb + (this.totle_num % this.cur_page_lenb == 0 ? 0 : 1); string page_info = string.Format("{0}/{1}", 1, totle_page_num2); this.label_baifen1.Text = page_info; this.init_ljjldgv(); } }
private void send_bt_Click(object sender, EventArgs e) { Maticsoft.BLL.parts use = new Maticsoft.BLL.parts(); Maticsoft.Model.parts us = new parts() { PN = bom_no_tb.Text, //name = bomname_tb.Text, //jobnum = gdno_tb.Text, //ARef = scbh_tb.Text, //size= cicun_tb.Text, //sm= sandsm_tb.Text, Barcode = tm_tb.Text, }; use.Add(us); MessageBox.Show("保存成功"); foreach (Control Ctrol in this.Controls) { if (Ctrol is TextBox) { Ctrol.Text = ""; } } this.Close(); }
private void button1_Click(object sender, EventArgs e) { try { if (textBox_ljh.Text == "") { MessageBox.Show("零件号为空"); return; } if (textBox_lxm.Text == "") { MessageBox.Show("序列号为空"); return; } if (textbox_gongdan.Text == "") { MessageBox.Show("工单号为空"); return; } if (comboBox1.SelectedIndex < 0) { MessageBox.Show("请选择正确的类型"); return; } Maticsoft.BLL.parts part_bll = new Maticsoft.BLL.parts(); List <Maticsoft.Model.parts> parts_list = part_bll.GetModelList(string.Format(" PN = '{0}'", textBox_ljh.Text)); if (parts_list.Count > 0) { Maticsoft.Model.parts parts_exmode = parts_list[0]; parts_exmode.Barcode = textBox_lxm.Text; parts_exmode.PN = textBox_ljh.Text; parts_exmode.remark = "管理"; parts_exmode.gongdan = textbox_gongdan.Text; parts_exmode.componentId = this.comp_list[comboBox1.SelectedIndex].componentId; if (part_bll.Update(parts_exmode)) { MessageBox.Show("更新成功"); } else { MessageBox.Show("更新失败"); } } else { Maticsoft.Model.parts parts_mode = new Maticsoft.Model.parts() { Barcode = textBox_lxm.Text, PN = textBox_ljh.Text, remark = "管理", gongdan = textbox_gongdan.Text, componentId = this.comp_list[comboBox1.SelectedIndex].componentId, }; if (part_bll.Add(parts_mode)) { MessageBox.Show("添加成功"); } else { MessageBox.Show("添加失败"); } } } catch (Exception err) { MessageBox.Show(err.Message); } finally { this.DialogResult = DialogResult.OK; } }
private void import_bt_Click(object sender, EventArgs e) { //string filepath = ""; //OpenFileDialog opf = new OpenFileDialog(); //if (opf.ShowDialog() == DialogResult.OK) //{ // filepath = opf.FileName; //} DataSet ds = new DataSet(); System.Data.DataTable dt = null; OpenFileDialog sflg = new OpenFileDialog(); sflg.Filter = "Excel(*.xls)|*.xls|Excel(*.xlsx)|*.xlsx"; if (sflg.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { return; } FileStream fs = new FileStream(sflg.FileName, FileMode.Open, FileAccess.Read); NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(fs); int sheetCount = book.NumberOfSheets; for (int sheetIndex = 0; sheetIndex < sheetCount; sheetIndex++) { string st_name = book.GetSheetName(sheetIndex); NPOI.SS.UserModel.ISheet sheet = book.GetSheetAt(sheetIndex); if (sheet == null) { continue; } NPOI.SS.UserModel.IRow row = sheet.GetRow(0); if (row == null) { continue; } int firstCellNum = row.FirstCellNum; int lastCellNum = row.LastCellNum; if (firstCellNum == lastCellNum) { continue; } dt = new System.Data.DataTable(sheet.SheetName); dt.Columns.Add("PN", typeof(string)); //MessageBox.Show(dt.Columns["bushe_xianshu"].DataType.ToString()); //dt.Columns.Add("", typeof(int)); dt.Columns.Add("name", typeof(string)); dt.Columns.Add("jobnum", typeof(string)); dt.Columns.Add("ARef", typeof(string)); dt.Columns.Add("size", typeof(string)); dt.Columns.Add("sm", typeof(string)); dt.Columns.Add("Barcode", typeof(string)); lastCellNum = 7; for (int i = firstCellNum; i < lastCellNum; i++) { dt.Columns.Add(row.GetCell(i).StringCellValue, typeof(string)); } for (int i = 1; i <= sheet.LastRowNum; i++) { DataRow newRow = dt.Rows.Add(); for (int j = firstCellNum; j < lastCellNum; j++) { newRow[j] = sheet.GetRow(i).GetCell(j).StringCellValue; } } NPOI.SS.UserModel.IRow row0 = sheet.GetRow(0); ds.Tables.Add(dt); main_gc.DataSource = ds.Tables[0]; } for (int i = 0; i < gridView1.RowCount; i++) { string LJH = gridView1.GetRowCellValue(i, "PN").ToString(); string mc = gridView1.GetRowCellValue(i, "name").ToString(); string gdh = gridView1.GetRowCellValue(i, "jobnum").ToString(); string BH = gridView1.GetRowCellValue(i, "ARef").ToString(); string cc = gridView1.GetRowCellValue(i, "size").ToString(); string dsm = gridView1.GetRowCellValue(i, "sm").ToString(); string tm = gridView1.GetRowCellValue(i, "Barcode").ToString(); Maticsoft.BLL.parts use = new Maticsoft.BLL.parts(); Maticsoft.Model.parts us = new parts() { PN = LJH, //name = mc, //jobnum = gdh, //ARef = BH, //size = cc, //sm = dsm, Barcode = tm, }; use.Add(us); } DevExpress.XtraEditors.XtraMessageBox.Show("导入成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //MessageBox.Show("已成功导入"); Maticsoft.BLL.parts pr = new Maticsoft.BLL.parts(); DataSet ds2 = pr.GetAllList(); main_gc.DataSource = ds2.Tables[0]; }