//} public Hashtable GetProductCTTable2() { Hashtable ctTable = new Hashtable(); try { DataSet dataSet = null; //string strSql = "SELECT * FROM tlb_product ORDER BY CREATE_TIME ASC"; string strSql = "SELECT * FROM tlb_product "; dataSet = MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, strSql); if (dataSet != null) { foreach (DataRow row in dataSet.Tables[0].Rows) { ProductionMDL mdl = ProductionMDL.ParseDataRow(row); CTUnitMDL unit = new CTUnitMDL(); unit.PN = mdl.PN; unit.CT = mdl.CT; unit.EMS = mdl.EMS; unit.OP = mdl.OP; ctTable.Add(mdl.PN, unit); } } return(ctTable); } catch { throw; } }
/// <summary> /// 查询过去CTUNIT /// </summary> /// <param name="LineID"></param> /// <param name="ems"></param> /// <returns></returns> public CTUnitMDL GetCTUnit(string lineid, int ems) { CTUnitMDL unit = null; try { int id = 0; Int32.TryParse(lineid, out id); if (id <= 0) { return(null); } string strSql = "SELECT * FROM tlb_product WHERE PLID='{0}' AND EMS={1}"; strSql = string.Format(strSql, id.ToString(), ems); DataSet dataSet = null; dataSet = MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, strSql); if (dataSet != null && dataSet.Tables[0].Rows.Count > 0) { ProductionMDL mdl = ProductionMDL.ParseDataRow(dataSet.Tables[0].Rows[0]); unit = new CTUnitMDL(); unit.PN = mdl.PN; unit.CT = mdl.CT; unit.EMS = mdl.EMS; unit.OP = mdl.OP; return(unit); } else { return(null); } } catch { return(null); } }
public ProductionMDL GetProductInfo(string lineID, int ems) { ProductionMDL mdl = null; try { string strSql = string.Empty; int nline = 0; Int32.TryParse(lineID, out nline); if (nline <= 0) { return(null); } strSql = "select * from tlb_product where PLID='{0}' and EMS='{1}'"; strSql = string.Format(strSql, nline.ToString(), ems); DataSet dataSet = MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, strSql); if (dataSet == null || dataSet.Tables.Count <= 0) { return(null); } //解析数据 mdl = ProductionMDL.ParseDataRow(dataSet.Tables[0].Rows[0]); return(mdl); } catch { throw; } }
private void btConvert_Click(object sender, EventArgs e) { if (this.txtPath.Text == null || this.txtPath.Text == String.Empty) { MessageBox.Show("请填选择导入文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } try { string selectFile = this.txtPath.Text.Trim(); if (selectFile == null || selectFile == string.Empty) { MessageBox.Show("未获导入数据信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //if (openFileDialog.ShowDialog() == DialogResult.Yes) //{ // csvTable = CSVFileHelper.OpenCSV(selectFile); //} //else //{ // this.txtPath.Text = String.Empty; // this.lbContent.Text = String.Empty; //} DataTable csvTable = null; csvTable = CSVFileHelper.OpenCSV(selectFile); if (csvTable == null || csvTable.Rows.Count <= 1) { MessageBox.Show("未获导入数据信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (csvTable.Columns == null) { MessageBox.Show("未获导入正确数据信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (csvTable.Columns.Count != 5) { MessageBox.Show("未获导入正确数据信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (csvTable.Columns[0].ColumnName != "PN") { MessageBox.Show("未获导入正确数据信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (MessageBox.Show("请确保产线为非生产状态,确定更新请选择‘是’", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) { return; } ProductDal dal = new ProductDal(); int countAdd = 0; int countRef = 0; int count = csvTable.Rows.Count; double div = (double)count / 100; double pogressValue = 0; foreach (DataRow row in csvTable.Rows) { ProductionMDL mdl = new ProductionMDL(); mdl = ProductionMDL.ParseDataRow(row); int ret = -1; pogressValue += div; if (dal.IsExist(mdl.PN) > 0) { ret = dal.UpdateProduction(mdl); if (ret > 0) { countRef++; UpdateContentInfo(mdl.PN + "更新成功", (int)div); } else { UpdateContentInfo(mdl.PN + "更新失败", (int)div); } } else { ret = dal.InsertProduction(mdl); if (ret > 0) { countAdd++; UpdateContentInfo(mdl.PN + "入库成功", (int)div); } else { UpdateContentInfo(mdl.PN + "入库失败", (int)div); } } } // UpdateContentInfo((countAdd+countRef).ToString() + "记录入库成功!"); MessageBox.Show((countAdd + countRef).ToString() + "记录入库成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (System.Exception ex) { MessageBox.Show(ex.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }