/// <summary> /// TODO 根据线别ID 查询线别信息 /// </summary> /// <param name="prodLineId"></param> /// <returns></returns> public ProdLine queryProdLineById(string prodLineId) { ProdLine prodLine = null; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT uuid,prodline_id,prodline_name,prodline_desc,dept_id,op_user,create_time FROM t_prodline where prodline_id=@prodLineId and del_flag is null"); MySqlParameter[] parameters = { new MySqlParameter("@prodLineId", MySqlDbType.VarChar, 900), }; parameters[0].Value = prodLineId; DataSet ds = SQLHelper.ExecuteDataset(SQLHelper.ConnectionString, CommandType.Text, strSql.ToString(), parameters); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { prodLine = new ProdLine(); Department department = new Department(); prodLine.Uuid = ds.Tables[0].Rows[0]["uuid"].ToString(); prodLine.ProdlineId = ds.Tables[0].Rows[0]["prodline_id"].ToString(); prodLine.ProdlineName = ds.Tables[0].Rows[0]["prodline_name"].ToString(); prodLine.ProdlineDesc = ds.Tables[0].Rows[0]["prodline_desc"].ToString(); department.DeptId = ds.Tables[0].Rows[0]["dept_id"].ToString(); prodLine.Department = department; prodLine.Opuser = ds.Tables[0].Rows[0]["op_user"].ToString(); prodLine.Createtime = ds.Tables[0].Rows[0]["create_time"].ToString(); } return(prodLine); }
/// <summary> /// TODO 根據部門ID 查詢該部門下所有線別 /// </summary> /// <param name="deptId"></param> /// <returns></returns> public List <ProdLine> queryPLByDeptId(string deptId) { List <ProdLine> prodLineList = null; StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT uuid,prodline_id,prodline_name,prodline_desc,op_user,create_time FROM t_prodline WHERE dept_id=@depId AND del_flag is null order by create_time"); MySqlParameter[] parameters = { new MySqlParameter("@depId", MySqlDbType.VarChar, 900), }; parameters[0].Value = deptId; DataSet ds = SQLHelper.ExecuteDataset(SQLHelper.ConnectionString, CommandType.Text, strSql.ToString(), parameters); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { prodLineList = new List <ProdLine>(); foreach (DataRow dr in ds.Tables[0].Rows) { ProdLine prodLine = new ProdLine(); prodLine.Uuid = dr["uuid"].ToString(); prodLine.ProdlineId = dr["prodline_id"].ToString(); prodLine.ProdlineName = dr["prodline_name"].ToString(); prodLine.ProdlineDesc = dr["prodline_desc"].ToString(); prodLine.Opuser = dr["op_user"].ToString(); prodLine.Createtime = dr["create_time"].ToString(); prodLineList.Add(prodLine); } } return(prodLineList); }
/// <summary> /// TODO 保存线别信息 /// </summary> /// <param name="prodLine"></param> /// <returns></returns> public bool saveProdLine(ProdLine prodLine) { bool saveMark = true; StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_prodline (uuid,prodline_name,prodline_desc,dept_id,op_user,create_time)"); strSql.Append("values(@uuid,@prodlineName,@prodlineDesc,@deptId,@opuser,@createtime)"); MySqlParameter[] parameters = { new MySqlParameter("@uuid", MySqlDbType.VarChar, 900), new MySqlParameter("@prodlineName", MySqlDbType.VarChar, 900), new MySqlParameter("@prodlineDesc", MySqlDbType.VarChar, 900), new MySqlParameter("@deptId", MySqlDbType.VarChar, 900), new MySqlParameter("@opuser", MySqlDbType.VarChar, 900), new MySqlParameter("@createtime", MySqlDbType.VarChar, 900) }; parameters[0].Value = prodLine.Uuid; parameters[1].Value = prodLine.ProdlineName; parameters[2].Value = prodLine.ProdlineDesc; parameters[3].Value = prodLine.Department.DeptId; parameters[4].Value = prodLine.Opuser; parameters[5].Value = prodLine.Createtime; int rows = SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionString, CommandType.Text, strSql.ToString(), parameters); if (rows > 0) { saveMark = true; } else { saveMark = false; } return(saveMark); }
public double GetScrapWeight(int plantID, int lineID, int shiftID, DateTime productionDate) { double returnValue = 0; Plant plant = _repository.Repository <Plant>().GetById(plantID); UnitOfMeasure defaultUom = plant.UnitOfMeasureDefaults.First(m => m.UnitOfMeasureType.Code == "W").UnitOfMeasure; ProdLine line = _repository.Repository <ProdLine>().GetById(lineID); ProdLineType lineType = _repository.Repository <ProdLineType>().GetById(line.LineTypeID); Application.UoMConversionService convert = new Application.UoMConversionService(); double result = 100; /* * var result = _repository.Repository<TPOLineScrap>().GetAllBy( * p => p.PlantID == plantID && * p.ShiftID == shiftID && * p.WorkOrder.LineID == lineID && * p.ProductionDate == productionDate).Sum( * p => convert.ConvertUoM(p.WeightUoMID, (decimal)p.Weight, defaultUom.ID) * ); * * returnValue = (double)Math.Round(result, 0); */ returnValue = result; return(returnValue); }
private string GetScrapCodeIM(ProdLine prodLine, DateTime productionDate) { string newCode = string.Empty; var labelCode = string.Format("S{0}{1}{2}", prodLine.LabelID.ToString("00"), (productionDate.Year % 100).ToString("00"), productionDate.DayOfYear.ToString("000")); return(newCode); }
/// <summary> /// TODO 保存线别信息 /// </summary> /// <param name="prodLine"></param> /// <returns></returns> public ProdLine saveProdLine(ProdLine prodLine) { ProdLine reProdLine = null; prodLine.Uuid = Auxiliary.Get_UUID(); prodLine.Createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); prodLine.Opuser = Auxiliary.loginName; if (prodLineDao.saveProdLine(prodLine)) { reProdLine = prodLineDao.queryProdLineByUUId(prodLine.Uuid); } return(reProdLine); }
public double GetCompletionPercentage(int plantID, int lineID, int workOrderID) { double returnValue = 0.0; WorkOrder workOrder = _repository.Repository <WorkOrder>().GetById(workOrderID); ProdLine line = _repository.Repository <ProdLine>().GetById(lineID); ProdLineType lineType = _repository.Repository <ProdLineType>().GetById(line.LineTypeID); double ran = 0; if (lineType.ProdLineTypeCode == "IM") { ran = 0; /* * _repository.Repository<IMProd>().GetAllBy( * p => p.ProdLineID == lineID && * p.WorkOrderID == workOrder.ID && * p.IMProductID == workOrder.IMProductID && * p.PlantID == plantID).Sum(p => p.PartsCarton); */ } else { ran = 0; /* * ran = _repository.Repository<TPOCProductRoll>().GetAllBy( * p => p.LineID == lineID && * p.WorkOrderID == workOrder.ID && * p.ProductID == workOrder.TPOProductID && * p.PlantID == plantID).Sum( * p => (p.Length * p.TPOProduct.Width) == null ? 0 : (p.Length * p.TPOProduct.Width) * ); */ } if (workOrder.RunArea > 0) { returnValue = (ran / workOrder.RunArea); } return(returnValue); }
private void button1_Click(object sender, EventArgs e) { if (this.textBox2.Text == null || this.textBox2.Text.Trim() == "") { MessageBox.Show("線別名稱不能為空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.textBox2.Focus(); return; } if (this.textBox3.Text == null || this.textBox2.Text.Trim() == "") { MessageBox.Show("線別描述不能為空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.textBox3.Focus(); return; } if (this.textBox1.Text != null && this.textBox1.Text.Trim() != "") { MessageBox.Show("線別已經保存,請勿重複保存!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (this.textBox2.Text == null || this.textBox2.Text.Trim() == "") { MessageBox.Show("請維護線別名稱!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.textBox2.Focus(); } ProdLine prodLine = new ProdLine(); Department department = new Department(); prodLine.ProdlineName = this.textBox2.Text.Trim(); prodLine.ProdlineDesc = this.textBox3.Text.Trim(); department.DeptId = this.comboBox1.SelectedValue.ToString().Trim(); prodLine.Department = department; ProdLine reProdLine = prodLineService.saveProdLine(prodLine); if (reProdLine != null) { this.textBox1.Text = reProdLine.ProdlineId; this.textBox4.Text = reProdLine.Createtime; MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("保存失敗,請維護線別描述信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.textBox2.Focus(); } }
private string GetScrapCodeTPO(ProdLine prodLine, DateTime productionDate) { string newCode = string.Empty; var labelCode = string.Format("S{0}{1}{2}", prodLine.LabelID.ToString("00"), (productionDate.Year % 100).ToString("00"), productionDate.DayOfYear.ToString("000")); var lastEntity = _repository.Repository <TPOLineScrap>().GetAllBy(s => s.ProdLinesID == prodLine.ID && s.Code.StartsWith(labelCode)).OrderByDescending(s => s.ID).FirstOrDefault(); int max = 0; if (lastEntity != null) { int.TryParse(lastEntity.Code.Substring(lastEntity.Code.Length - 4), out max); } newCode = string.Format("{0}{1}", labelCode, max.ToString().PadLeft(3, '0')); return(newCode); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { string deptId = this.comboBox1.SelectedValue.ToString(); List <ProdLine> prodLineList = prodLineService.queryPLByDeptId(deptId); this.comboBox2.ValueMember = "ProdlineId"; this.comboBox2.DisplayMember = "ProdlineName"; this.comboBox2.DataSource = prodLineList; this.comboBox2.SelectedIndex = 0; if (userProdLine != null) { this.comboBox2.Enabled = false; var items = this.comboBox2.Items; for (int i = 0; i < items.Count; i++) { ProdLine iteratorProdLine = items[i] as ProdLine; if (userProdLine.ProdlineId.Equals(iteratorProdLine.ProdlineId)) { this.comboBox2.SelectedItem = iteratorProdLine; break; } } } }
private void CreateRules_Load(object sender, EventArgs e) { this.numericUpDown3.Value = 2; //设置默认打印张数:2 DataGridViewTextBoxColumn column = new DataGridViewTextBoxColumn(); column.Name = "ctCode"; column.DataPropertyName = "ct_code";//对应数据源的字段 column.HeaderText = "CT碼"; column.Width = 100; this.dataGridView1.Columns.Add(column); DataGridViewTextBoxColumn column1 = new DataGridViewTextBoxColumn(); column1.Name = "delMatno"; column1.DataPropertyName = "del_matno";//对应数据源的字段 column1.HeaderText = "出貨料號"; column1.Width = 100; this.dataGridView1.Columns.Add(column1); DataGridViewTextBoxColumn column2 = new DataGridViewTextBoxColumn(); column2.Name = "cusName"; column2.DataPropertyName = "cus_name";//对应数据源的字段 column2.HeaderText = "客戶名稱"; column2.Width = 100; this.dataGridView1.Columns.Add(column2); DataGridViewTextBoxColumn column3 = new DataGridViewTextBoxColumn(); column3.Name = "cusNo"; column3.DataPropertyName = "cus_no";//对应数据源的字段 column3.HeaderText = "客戶編號"; column3.Width = 80; this.dataGridView1.Columns.Add(column3); DataGridViewTextBoxColumn column4 = new DataGridViewTextBoxColumn(); column4.Name = "workNo"; column4.DataPropertyName = "work_no";//对应数据源的字段 column4.HeaderText = "工單號"; column4.Width = 100; this.dataGridView1.Columns.Add(column4); DataGridViewTextBoxColumn column5 = new DataGridViewTextBoxColumn(); column5.Name = "woQuantity"; column5.DataPropertyName = "wo_quantity";//对应数据源的字段 column5.HeaderText = "工單數量"; column5.Width = 80; this.dataGridView1.Columns.Add(column5); DataGridViewTextBoxColumn column6 = new DataGridViewTextBoxColumn(); column6.Name = "cusMatno"; column6.DataPropertyName = "cus_matno";//对应数据源的字段 column6.HeaderText = "客戶料號"; column6.Width = 100; this.dataGridView1.Columns.Add(column6); //初始化 部門下拉列表; List <Department> listDepartment = departmentService.queryDepartmentList(""); this.comboBox1.ValueMember = "DeptId"; this.comboBox1.DisplayMember = "DeptName"; this.comboBox1.DataSource = listDepartment; this.comboBox1.SelectedIndex = 0; User user = userService.queryByUsername(Auxiliary.loginName); if (user.ProdLine != null && !("").Equals(user.ProdLine)) { this.comboBox1.Enabled = false; userProdLine = prodLineService.queryProdLineById(user.ProdLine); if (userProdLine != null) { var items = this.comboBox1.Items; for (int i = 0; i < items.Count; i++) { Department iteratorDept = items[i] as Department; if (userProdLine.Department.DeptId.Equals(iteratorDept.DeptId)) { this.comboBox1.SelectedItem = iteratorDept; break; } } } } string deptId = this.comboBox1.SelectedValue.ToString(); List <ProdLine> prodLineList = prodLineService.queryPLByDeptId(deptId); this.comboBox2.ValueMember = "ProdlineId"; this.comboBox2.DisplayMember = "ProdlineName"; this.comboBox2.DataSource = prodLineList; this.comboBox2.SelectedIndex = 0; if (userProdLine != null) { this.comboBox2.Enabled = false; var items = this.comboBox2.Items; for (int i = 0; i < items.Count; i++) { ProdLine iteratorProdLine = items[i] as ProdLine; if (userProdLine.ProdlineId.Equals(iteratorProdLine.ProdlineId)) { this.comboBox2.SelectedItem = iteratorProdLine; break; } } } DataTable itemTable2 = new DataTable(); // construct selects value DataColumn columnType; DataRow rowType; columnType = new DataColumn("Name"); itemTable2.Columns.Add(columnType); columnType = new DataColumn("Value"); itemTable2.Columns.Add(columnType); rowType = itemTable2.NewRow(); rowType["Name"] = "yyyy-MM-dd"; rowType["Value"] = "yyyy-MM-dd"; itemTable2.Rows.Add(rowType); rowType = itemTable2.NewRow(); rowType["Name"] = "yyyyMMdd"; rowType["Value"] = "yyyyMMdd"; itemTable2.Rows.Add(rowType); rowType = itemTable2.NewRow(); rowType["Name"] = "yyyy/MM/dd"; rowType["Value"] = "yyyy/MM/dd"; itemTable2.Rows.Add(rowType); this.comboBox3.DisplayMember = "Name"; this.comboBox3.ValueMember = "Value"; this.comboBox3.DataSource = itemTable2; }
private void CreateRules_Load(object sender, EventArgs e) { //初始化 部門下拉列表; List <Department> listDepartment = departmentService.queryDepartmentList(""); this.comboBox1.ValueMember = "DeptId"; this.comboBox1.DisplayMember = "DeptName"; this.comboBox1.DataSource = listDepartment; this.comboBox1.SelectedIndex = 0; User user = userService.queryByUsername(Auxiliary.loginName); if (user.ProdLine != null && !("").Equals(user.ProdLine)) { this.comboBox1.Enabled = false; userProdLine = prodLineService.queryProdLineById(user.ProdLine); if (userProdLine != null) { var items = this.comboBox1.Items; for (int i = 0; i < items.Count; i++) { Department iteratorDept = items[i] as Department; if (userProdLine.Department.DeptId.Equals(iteratorDept.DeptId)) { this.comboBox1.SelectedItem = iteratorDept; break; } } } } string deptId = this.comboBox1.SelectedValue.ToString(); List <ProdLine> prodLineList = prodLineService.queryPLByDeptId(deptId); this.comboBox2.ValueMember = "ProdlineId"; this.comboBox2.DisplayMember = "ProdlineName"; this.comboBox2.DataSource = prodLineList; this.comboBox2.SelectedIndex = 0; if (userProdLine != null) { this.comboBox2.Enabled = false; var items = this.comboBox2.Items; for (int i = 0; i < items.Count; i++) { ProdLine iteratorProdLine = items[i] as ProdLine; if (userProdLine.ProdlineId.Equals(iteratorProdLine.ProdlineId)) { this.comboBox2.SelectedItem = iteratorProdLine; break; } } } DataTable itemTable2 = new DataTable(); // construct selects value DataColumn columnType; DataRow rowType; columnType = new DataColumn("Name"); itemTable2.Columns.Add(columnType); columnType = new DataColumn("Value"); itemTable2.Columns.Add(columnType); rowType = itemTable2.NewRow(); rowType["Name"] = "yyyy-MM-dd"; rowType["Value"] = "yyyy-MM-dd"; itemTable2.Rows.Add(rowType); rowType = itemTable2.NewRow(); rowType["Name"] = "yyyyMMdd"; rowType["Value"] = "yyyyMMdd"; itemTable2.Rows.Add(rowType); rowType = itemTable2.NewRow(); rowType["Name"] = "yyyy/MM/dd"; rowType["Value"] = "yyyy/MM/dd"; itemTable2.Rows.Add(rowType); this.comboBox6.DisplayMember = "Name"; this.comboBox6.ValueMember = "Value"; this.comboBox6.DataSource = itemTable2; this.numericUpDown3.Value = 2; //设置默认打印张数:2 this.numericUpDown2.Value = 1; }
public double GetScrapPercent(int plantID, int lineID, int shiftID, DateTime productionDate) { double returnValue = 0; Plant plant = _repository.Repository <Plant>().GetById(plantID); UnitOfMeasure defaultUom = plant.UnitOfMeasureDefaults.First(m => m.UnitOfMeasureType.Code == "W").UnitOfMeasure; ProdLine line = _repository.Repository <ProdLine>().GetById(lineID); ProdLineType lineType = _repository.Repository <ProdLineType>().GetById(line.LineTypeID); ProductionShift shift = _repository.Repository <ProductionShift>().GetById(shiftID); Application.UoMConversionService convert = new Application.UoMConversionService(); var scrap = 0; /* * var scrap = _repository.Repository<TPOLineScrap>().GetAllBy( * p => p.PlantID == plantID && * p.ShiftID == shiftID && * p.WorkOrder.LineID == lineID && * p.ProductionDate == productionDate).Sum( * p => convert.ConvertUoM(p.WeightUoMID, (decimal)p.Weight, defaultUom.ID) * ); */ if (lineType.ProdLineTypeCode == "IM") { var prod = 0; /* * var prod = _repository.Repository<IMProd>().GetAllBy( * p => p.ProdLineID == lineID && * p.ProdShift == shift.Code && * p.PlantID == plantID && * p.ProdDate == productionDate).Sum( * p => convert.ConvertUoM(p.WeightUOM, (decimal)p.CartonWeight, defaultUom.ID) * ); */ if (prod > 0) { returnValue = (double)(scrap / prod); } } else { var prod = 0; /* * var prod = _repository.Repository<TPOCProductRoll>().GetAllBy( * p => p.LineID == lineID && * p.ShiftID == shiftID && * p.PlantID == plantID && * p.ProductionDate == productionDate).Sum( * p => convert.ConvertUoM(p.WeightUoMID, (decimal)p.Weight, defaultUom.ID) * ); */ if (prod > 0) { returnValue = (double)(scrap / prod); } } return(returnValue); }