/// <summary> /// /// </summary> private void InitalCombox() { try { //this.cbLineNum.DataSource = Enum.GetValues(typeof(COM.LineType)); //this.cbLineNum.SelectedIndex = 0; //this.cbLineNum.SelectedIndex = this._lineID-1; this.lbLineID.Text = _lineID.ToString() + "号产线"; //if (isUpdate) //{ // this.cbLineNum.SelectedIndex = this._lineID; //} // ProductDal dal = new ProductDal(); ProductSQLiteDal dal = new ProductSQLiteDal(); this.cbProductioName.DataSource = dal.GetProductionNames(); if (this.cbProductioName.DataSource != null) { this.cbProductioName.SelectedIndex = 0; } if (isUpdate) { this.cbProductioName.Text = plan.BreakeID; } this.cbShift.DataSource = Enum.GetValues(typeof(COMM.ShiftType)); this.cbShift.SelectedIndex = 0; if (isUpdate) { this.cbShift.SelectedIndex = (int)plan.Shift; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void LoadDataGridView() { try { this.dataGridView1.Rows.Clear(); //ProductDal dal = new ProductDal(); ProductSQLiteDal dal = new ProductSQLiteDal(); infos = dal.GetProductionInfos(); //this.dataGridView1.DataSource = bindingSource1; // Set the DataGridView control's border. dataGridView1.BorderStyle = BorderStyle.Fixed3D; if (infos != null && infos.Rows.Count > 0) { for (int i = 0; i < infos.Rows.Count; i++) { DataRow row = infos.Rows[i]; this.dataGridView1.Rows.Add(Convert.ToString(row["lineid"]) + "号线", Convert.ToString(row["brakename"]), Convert.ToString(row["brakeid"]), Convert.ToString(row["brakecode"]), //Convert.ToString(row["createtime"]), Convert.ToString(row["factory"]), "修 改", "删 除"); } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); CLog.WriteErrLogInTrace(ex.Message); } this.Cursor = Cursors.Default; }
private void btAddDevice_Click(object sender, EventArgs e) { ProductionInfo addInfoForm = new ProductionInfo(); if (addInfoForm.ShowDialog() == DialogResult.OK) { ProductSQLiteDal dal = new ProductSQLiteDal(); //ProductDal dal = new ProductDal(); if (dal.InsertProduction(addInfoForm.Production) > 0) { this.LoadDataGridView(); MessageBox.Show("添加产品信息成功!"); } else { MessageBox.Show("添加产品信息失败!"); } } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { this.dataGridView1.CellValueChanged -= new DataGridViewCellEventHandler(dataGridView1_CellContentClick); DataRow rd = null; switch (e.ColumnIndex) { case 5: ProductionInfo addInfoForm = new ProductionInfo(); addInfoForm.IsUpdate = true; rd = this.infos.Rows[e.RowIndex]; ProductionMDL info = new ProductionMDL(); // info.Load(rd); addInfoForm.Production = info; if (addInfoForm.ShowDialog() == DialogResult.OK) { // ProductDal dal = new ProductDal(); ProductSQLiteDal dal = new ProductSQLiteDal(); if (dal.UpdateProduction(info) > 0) { this.LoadDataGridView(); MessageBox.Show("修改产品信息成功!"); } else { MessageBox.Show("修改产品信息失败!"); } } break; case 6: if (MessageBox.Show("确定要删除该产品信息吗?", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK) { rd = this.infos.Rows[e.RowIndex]; int id = Convert.ToInt32(rd["tid"]); //ProductDal dal = new ProductDal(); ProductSQLiteDal dal = new ProductSQLiteDal(); if (dal.DeleteProduction(id) > 0) { this.LoadDataGridView(); } else { MessageBox.Show("删除产品信息失败!"); } } break; default: break; } this.dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellContentClick); }