private bool _getTargetPower(CvSystemSpecificPurchasePowerOutputProperty dataItem) { bool result = true; try { TARGET_POWER.Text = ""; MAX_VOLTAGE_STEP.Text = ""; dataGridView1.Rows.Clear(); List <CvSystemSpecificPurchasePowerOutputProperty> list = _cvSystemSpecificPurchasePowerOutputController.SearchBySystemIdAndPurchaseIdAndProcessId(dataItem); foreach (CvSystemSpecificPurchasePowerOutputProperty systemSpecificConfigPower in list) { TARGET_POWER.Text = systemSpecificConfigPower.TARGET_POWER.ToString(); MAX_VOLTAGE_STEP.Text = systemSpecificConfigPower.MAX_VOLTAGE_STEP.ToString(); break; } foreach (CvSystemSpecificPurchasePowerOutputProperty systemSpecificConfigPower in list) { dataGridView1.Rows.Add(systemSpecificConfigPower.NO, systemSpecificConfigPower.POWER_PERCENT_FROM, systemSpecificConfigPower.POWER_PERCENT_TO, systemSpecificConfigPower.VOLTAGE_STEP, systemSpecificConfigPower.WAIT_TIME, "Delete"); } } catch (Exception ex) { CommonClassLibraryGlobal.showError(ex.Message); result = false; } return(result); }
public List <CvSystemSpecificPurchasePowerOutputProperty> SearchBySystemIdAndPurchaseIdAndProcessId(CvSystemSpecificPurchasePowerOutputProperty dataItem) { List <CvSystemSpecificPurchasePowerOutputProperty> listItem = new List <CvSystemSpecificPurchasePowerOutputProperty>(); try { _resultData = _model.SearchBySystemIdAndPurchaseIdAndProcessId(dataItem); if (_resultData.StatusOnDb == true) { foreach (DataRow row in _resultData.ResultOnDb.Rows) { CvSystemSpecificPurchasePowerOutputProperty productProperty = new CvSystemSpecificPurchasePowerOutputProperty { ID = row["ID"].ToString(), SYSTEM_ID = row["SYSTEM_ID"].ToString(), PURCHASE_ID = row["PURCHASE_ID"].ToString(), PROCESS_NAME = row["PROCESS_NAME"].ToString(), NO = row["NO"].ToString(), TARGET_POWER = row["TARGET_POWER"].ToString(), POWER_PERCENT_FROM = row["POWER_PERCENT_FROM"].ToString(), POWER_PERCENT_TO = row["POWER_PERCENT_TO"].ToString(), MAX_VOLTAGE_STEP = row["MAX_VOLTAGE_STEP"].ToString(), VOLTAGE_STEP = row["VOLTAGE_STEP"].ToString(), WAIT_TIME = row["WAIT_TIME"].ToString(), CREATE_DATE = row["CREATE_DATE"].ToString(), LAST_DATE = row["LAST_DATE"].ToString(), IP_ADDRESS = row["IP_ADDRESS"].ToString(), NAME_ADDRESS = row["NAME_ADDRESS"].ToString(), USER_CREATE = row["USER_CREATE"].ToString(), USER_UPDATE = row["USER_UPDATE"].ToString(), INUSE = row["INUSE"].ToString(), DESCRIPTION = row["DESCRIPTION"].ToString(), }; listItem.Add(productProperty); } } else { MessageBox.Show(_resultData.MessageOnDb, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(listItem); }
public string SearchBySystemIdAndPurchaseIdAndProcessId(CvSystemSpecificPurchasePowerOutputProperty dataItem) { string sql = @" SELECT * FROM tableName WHERE PURCHASE_ID = 'dataItem.PURCHASE_ID' AND SYSTEM_ID = 'dataItem.SYSTEM_ID' AND PROCESS_NAME = 'dataItem.PROCESS_NAME' AND INUSE = 1 "; sql = sql.Replace("tableName", tableName); sql = sql.Replace("dataItem.PURCHASE_ID", dataItem.PURCHASE_ID); sql = sql.Replace("dataItem.PROCESS_NAME", dataItem.PROCESS_NAME); sql = sql.Replace("dataItem.SYSTEM_ID", dataItem.SYSTEM_ID); return(sql); }
private void processClick(object sender, EventArgs e) { btnResonatorTest.BackColor = Color.FromArgb(181, 234, 215); btnThermalScreening.BackColor = Color.FromArgb(181, 234, 215); btnPreBurnIn1.BackColor = Color.FromArgb(181, 234, 215); btnPreKinkTest.BackColor = Color.FromArgb(181, 234, 215); btnSRS1.BackColor = Color.FromArgb(181, 234, 215); btnPreBurnIn2.BackColor = Color.FromArgb(181, 234, 215); btnKinkTest.BackColor = Color.FromArgb(181, 234, 215); btnBurnIn.BackColor = Color.FromArgb(181, 234, 215); btnPostBI.BackColor = Color.FromArgb(181, 234, 215); btnSRS2.BackColor = Color.FromArgb(181, 234, 215); Button btn = (Button)sender; //txtProcessSelected.Text = btn.Name.Replace("btn", "").Replace("no", ""); txtProcessSelected.Text = btn.Text; //CommonClass.targetPower = txtTargetPower.Text; //CommonClass.processName = txtProcess.Text; flowLayoutPanelProcess.Controls["btn" + btn.Name.Replace("btn", "").Replace("no", "")].BackColor = Color.FromArgb(245, 183, 177); CvSystemSpecificPurchasePowerOutputProperty CvSystemSpecificProcessPowerOutputProperty = new CvSystemSpecificPurchasePowerOutputProperty { SYSTEM_ID = frmSystem.SYSTEM_ID, PURCHASE_ID = frmSystemSpecificPurchase.PURCHASE_ID, PROCESS_NAME = txtProcessSelected.Text, }; CvSystemSpecificPurchaseProperty CvSystemSpecificProcessProperty = new CvSystemSpecificPurchaseProperty() { SYSTEM_ID = frmSystem.SYSTEM_ID, PURCHASE_ID = frmSystemSpecificPurchase.PURCHASE_ID, PROCESS_NAME = txtProcessSelected.Text, }; if (_getInitialVoltage(CvSystemSpecificProcessProperty) == false) { this.Close(); } if (_getTargetPower(CvSystemSpecificProcessPowerOutputProperty) == false) { this.Close(); } _backToSet(); }
public string Delete(CvSystemSpecificPurchasePowerOutputProperty dataItem) { string sql = @" UPDATE tableName SET INUSE = 0 , USER_UPDATE = 'dataItem.USER_UPDATE' , LAST_DATE = NOW() WHERE PURCHASE_ID = 'dataItem.PURCHASE_ID' AND SYSTEM_ID = 'dataItem.SYSTEM_ID' AND PROCESS_NAME = 'dataItem.PROCESS_NAME' AND INUSE = 1 "; sql = sql.Replace("tableName", tableName); sql = sql.Replace("dataItem.PURCHASE_ID", dataItem.PURCHASE_ID); sql = sql.Replace("dataItem.PROCESS_NAME", dataItem.PROCESS_NAME); sql = sql.Replace("dataItem.SYSTEM_ID", dataItem.SYSTEM_ID); sql = sql.Replace("dataItem.USER_UPDATE", dataItem.USER_UPDATE); return(sql); }
public OutputOnDbProperty SearchBySystemIdAndPurchaseIdAndProcessId(CvSystemSpecificPurchasePowerOutputProperty dataItem) { _resultData = _service.SearchBySystemIdAndPurchaseIdAndProcessId(dataItem); return(_resultData); }
public string Insert(CvSystemSpecificPurchasePowerOutputProperty dataItem) { string sql = @"INSERT INTO tableName ( ID , SYSTEM_ID , PURCHASE_ID , PROCESS_NAME , NO , TARGET_POWER , POWER_PERCENT_FROM , POWER_PERCENT_TO , MAX_VOLTAGE_STEP , VOLTAGE_STEP , WAIT_TIME , IP_ADDRESS , NAME_ADDRESS , USER_CREATE , INUSE , DESCRIPTION ) ( SELECT 1 + coalesce((SELECT max(Id) FROM tableName), 0) , 'dataItem.SYSTEM_ID' , 'dataItem.PURCHASE_ID' , 'dataItem.PROCESS_NAME' , 'dataItem.NO' , 'dataItem.TARGET_POWER' , 'dataItem.POWER_PERCENT_FROM' , 'dataItem.POWER_PERCENT_TO' , 'dataItem.MAX_VOLTAGE_STEP' , 'dataItem.VOLTAGE_STEP' , 'dataItem.WAIT_TIME' , 'dataItem.IP_ADDRESS' , 'dataItem.NAME_ADDRESS' , 'dataItem.USER_CREATE' , 1 , 'dataItem.DESCRIPTION' )"; sql = sql.Replace("tableName", tableName); sql = sql.Replace("dataItem.SYSTEM_ID", dataItem.SYSTEM_ID); sql = sql.Replace("dataItem.PURCHASE_ID", dataItem.PURCHASE_ID); sql = sql.Replace("dataItem.PROCESS_NAME", dataItem.PROCESS_NAME); sql = sql.Replace("dataItem.NO", dataItem.NO); sql = sql.Replace("dataItem.TARGET_POWER", dataItem.TARGET_POWER); sql = sql.Replace("dataItem.POWER_PERCENT_FROM", dataItem.POWER_PERCENT_FROM); sql = sql.Replace("dataItem.POWER_PERCENT_TO", dataItem.POWER_PERCENT_TO); sql = sql.Replace("dataItem.MAX_VOLTAGE_STEP", dataItem.MAX_VOLTAGE_STEP); sql = sql.Replace("dataItem.VOLTAGE_STEP", dataItem.VOLTAGE_STEP); sql = sql.Replace("dataItem.WAIT_TIME", dataItem.WAIT_TIME); sql = sql.Replace("dataItem.CREATE_DATE", dataItem.CREATE_DATE); sql = sql.Replace("dataItem.LAST_DATE", dataItem.LAST_DATE); sql = sql.Replace("dataItem.IP_ADDRESS", dataItem.IP_ADDRESS); sql = sql.Replace("dataItem.NAME_ADDRESS", dataItem.NAME_ADDRESS); sql = sql.Replace("dataItem.USER_CREATE", dataItem.USER_CREATE); sql = sql.Replace("dataItem.USER_UPDATE", dataItem.USER_UPDATE); sql = sql.Replace("dataItem.INUSE", dataItem.INUSE); sql = sql.Replace("dataItem.DESCRIPTION", dataItem.DESCRIPTION); return(sql); }
private void btnSavePower_Click(object sender, EventArgs e) { if (txtProcessSelected.Text == "XXX") { CommonClassLibraryGlobal.showError("กรุณาเลือกโปรเซสที่ต้องการ"); return; } //-------------------------- ตรวจสอบข้อมูล ------------------------------------------ if (!double.TryParse(TARGET_POWER.Text, out CommonClassLibraryGlobal.chkDouble)) { CommonClassLibraryGlobal.showError("กรุณากรอก Target Power เป็นตัวเลขเท่านั้น"); TARGET_POWER.Text = ""; TARGET_POWER.Focus(); return; } if (!double.TryParse(MAX_VOLTAGE_STEP.Text, out CommonClassLibraryGlobal.chkDouble)) { CommonClassLibraryGlobal.showError("กรุณากรอก Max Voltage Step เป็นตัวเลขเท่านั้น"); MAX_VOLTAGE_STEP.Text = ""; MAX_VOLTAGE_STEP.Focus(); return; } if (double.Parse(MAX_VOLTAGE_STEP.Text) <= 0) { CommonClassLibraryGlobal.showError("กรุณากรอก Max Voltage Step ให้มากกว่า 0 "); return; } int percent = 0; for (int rows = 0; rows < dataGridView1.Rows.Count; rows++) { if (!int.TryParse(dataGridView1.Rows[rows].Cells[1].Value.ToString(), out CommonClassLibraryGlobal.chkInt)) { CommonClassLibraryGlobal.showError("กรุณากรอก Power From (%) เป็นตัวเลขจำนวนเต็มเท่านั้น "); return; } if (!int.TryParse(dataGridView1.Rows[rows].Cells[2].Value.ToString(), out CommonClassLibraryGlobal.chkInt)) { CommonClassLibraryGlobal.showError("กรุณากรอก Power To (%) เป็นตัวเลขจำนวนเต็มเท่านั้น "); return; } if (int.Parse(dataGridView1.Rows[rows].Cells[1].Value.ToString()) > int.Parse(dataGridView1.Rows[rows].Cells[2].Value.ToString())) { CommonClassLibraryGlobal.showError("กรุณากรอก Power From (%) ให้น้อยกว่า Power To (%) "); return; } if (!double.TryParse(dataGridView1.Rows[rows].Cells[3].Value.ToString(), out CommonClassLibraryGlobal.chkDouble)) { CommonClassLibraryGlobal.showError("กรุณากรอก Voltage Step (V) เป็นตัวเลขเท่านั้น "); return; } if (double.Parse(dataGridView1.Rows[rows].Cells[3].Value.ToString()) <= 0) { CommonClassLibraryGlobal.showError("กรุณากรอก Voltage Step (V) ให้มากกว่า 0 "); return; } if (double.Parse(dataGridView1.Rows[rows].Cells[3].Value.ToString()) > double.Parse(MAX_VOLTAGE_STEP.Text)) { CommonClassLibraryGlobal.showError("กรุณากรอก Voltage Step (V) ให้น้อยกว่าหรือเท่ากับ Max Voltage Step"); return; } if (!double.TryParse(dataGridView1.Rows[rows].Cells[4].Value.ToString(), out CommonClassLibraryGlobal.chkDouble)) { CommonClassLibraryGlobal.showError("กรุณากรอก Wait Time (S) เป็นตัวเลขเท่านั้น "); return; } } for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (int.Parse(dataGridView1.Rows[i].Cells[1].Value.ToString()) != percent) { CommonClassLibraryGlobal.showError("ไม่พบ Power (%) ที่ " + percent + " ของ No." + (i + 1)); return; } percent = int.Parse(dataGridView1.Rows[i].Cells[2].Value.ToString()) + 1; } if (percent - 1 != 100) { CommonClassLibraryGlobal.showError("กรุณากรอก Power To (%) ให้ครบ 100% "); return; } //-------------------------- End of ตรวจสอบข้อมูล ------------------------------------------ MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult dialogResult = MessageBox.Show("ต้องการบันทึกข้อมูล ?", "Message", buttons, MessageBoxIcon.Warning); if (dialogResult == DialogResult.No) { return; } List <CvSystemSpecificPurchasePowerOutputProperty> listItem = new List <CvSystemSpecificPurchasePowerOutputProperty>(); foreach (DataGridViewRow row in dataGridView1.Rows) { CvSystemSpecificPurchasePowerOutputProperty dataItem = new CvSystemSpecificPurchasePowerOutputProperty() { SYSTEM_ID = frmSystem.SYSTEM_ID, PURCHASE_ID = frmSystemSpecificPurchase.PURCHASE_ID, PROCESS_NAME = txtProcessSelected.Text, NO = row.Cells[0].Value.ToString(), TARGET_POWER = TARGET_POWER.Text, POWER_PERCENT_FROM = row.Cells[1].Value.ToString(), POWER_PERCENT_TO = row.Cells[2].Value.ToString(), MAX_VOLTAGE_STEP = MAX_VOLTAGE_STEP.Text, VOLTAGE_STEP = row.Cells[3].Value.ToString(), WAIT_TIME = row.Cells[4].Value.ToString(), IP_ADDRESS = CommonClassLibraryGlobal.IP, NAME_ADDRESS = CommonClassLibraryGlobal.HOST_NAME, USER_CREATE = CommonClassLibraryGlobal.OPERATOR_ID, USER_UPDATE = CommonClassLibraryGlobal.OPERATOR_ID, }; listItem.Add(dataItem); } if (_cvSystemSpecificPurchasePowerOutputController.InsertAndUpdateInuse(listItem) == true) { CommonClassLibraryGlobal.showSuccess("แก้ไขข้อมูลสำเร็จ"); return; } else { CommonClassLibraryGlobal.showSuccess("แก้ไขข้อมูลไม่สำเร็จ กรุณาลองใหม่อีกครั้ง"); return; } }