public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { WarehouseVTListVo inVo = (WarehouseVTListVo)vo; StringBuilder sql = new StringBuilder(); ValueObjectList <WarehouseVTListVo> voList = new ValueObjectList <WarehouseVTListVo>(); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append(@"select max(check_time) from t_vt_list_check where 1=1 "); if (!String.IsNullOrEmpty(inVo.MachineSerial)) { sql.Append(@" and machine_serial =:machine_serial"); sqlParameter.AddParameterString("machine_serial", inVo.MachineSerial); } sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { WarehouseVTListVo outVo = new WarehouseVTListVo { CheckTime = int.Parse(dataReader["check_time"].ToString()), }; voList.add(outVo); } dataReader.Close(); return(voList); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { WarehouseVTListVo inVo = (WarehouseVTListVo)vo; StringBuilder sql = new StringBuilder(); sql.Append(@"insert into t_vt_datalost(rfid, machine_serial, check_time, command) "); sql.Append(@"values(:rfid, :machine_serial, :check_time, :command)"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameter("rfid", inVo.RFId); sqlParameter.AddParameter("machine_serial", inVo.MachineSerial); sqlParameter.AddParameter("check_time", inVo.CheckTime); sqlParameter.AddParameter("command", inVo.Comment); WarehouseVTListVo outVo = new WarehouseVTListVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
private void ok_btn_Click(object sender, EventArgs e) { if (checkdata()) { WarehouseVTListVo outVo = new WarehouseVTListVo(); WarehouseVTListVo inVo = new WarehouseVTListVo() { RFId = rfid_txt.Text, MachineSerial = machine_serial_txt.Text, CheckTime = int.Parse(checktime_txt.Text), Comment = comment_txt.Text }; try { outVo = (WarehouseVTListVo)DefaultCbmInvoker.Invoke(new Cbm.AddListDatalostVTCbm(), inVo); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } if (outVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, machine_serial_txt.Text + " : " + machine_serial_txt.Text); logger.Info(messageData); popUpMessage.Information(messageData, Text); return; } } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { WarehouseVTListVo inVo = (WarehouseVTListVo)vo; StringBuilder sql = new StringBuilder(); sql.Append(@"update t_vt_list_check set machine_cd =:machine_cd check_time =:check_time, registration_user_cd =:registration_user_cd, value_last =:value_last, where check_id =:check_id"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameter("machine_cd", inVo.MachineCode); sqlParameter.AddParameter("check_time", inVo.CheckTime); sqlParameter.AddParameter("registration_user_cd", UserData.GetUserData().UserName); sqlParameter.AddParameter("value_last", inVo.ValueCheck); //execute SQL WarehouseVTListVo outVo = new WarehouseVTListVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
private void Countrow() { rowcount_cmb.DataSource = null; //WarehouseVTListVo outVo = new WarehouseVTListVo(); WarehouseVTListVo inVo = new WarehouseVTListVo() { CheckTime = int.Parse(checktime_cmb.Text), MachineSerial = machine_serial_cmb.Text, RFId = rfid_txt.Text, }; ValueObjectList <WarehouseVTListVo> assetvotype = (ValueObjectList <WarehouseVTListVo>)DefaultCbmInvoker.Invoke(new SearchCountRowVTListCbm(), inVo); rowcount_cmb.DisplayMember = "CounterRow"; rowcount_cmb.DataSource = assetvotype.GetList(); string counter = rowcount_cmb.Text; if (counter == "0") { insert_update = "Insert"; //insert data } else if (counter == "1") { insert_update = "Update"; } else { insert_update = "NA"; //tnhong bao tao thích do là cc gi t // } }
private void search_btn_Click(object sender, EventArgs e) { warehouse_list_dgv.Visible = false; if (checktime_cmb.Text != "" && (value_cmb.Text == "True" || value_cmb.Text == "False")) { warehouse_vt_dgv.Visible = true; datalost_dgv.Visible = false; try { WarehouseVTVo whvos = new WarehouseVTVo() { MachineSerial = machine_serial_cmb.Text, RFId = rfid_txt.Text, TimeCheck = int.Parse(checktime_cmb.Text), ValueResult = value_cmb.Text, }; ValueObjectList <WarehouseVTVo> listvo = (ValueObjectList <WarehouseVTVo>)DefaultCbmInvoker.Invoke(new Cbm.SearchResuftCheckVTCbm(), whvos); warehouse_vt_dgv.DataSource = listvo.GetList(); if (value_cmb.Text == "True") { valueTrue_lbl.Text = warehouse_vt_dgv.RowCount.ToString(); } if (value_cmb.Text == "False") { valueFalse_lbl.Text = warehouse_vt_dgv.RowCount.ToString(); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } } else if (value_cmb.Text == "NoData") { warehouse_vt_dgv.Visible = false; warehouse_list_dgv.Visible = false; datalost_dgv.Visible = true; try { WarehouseVTListVo whvos = new WarehouseVTListVo(); ValueObjectList <WarehouseVTListVo> listvo = (ValueObjectList <WarehouseVTListVo>)DefaultCbmInvoker.Invoke(new Cbm.SearchDatalostVTListCbm(), whvos); datalost_dgv.DataSource = listvo.GetList(); valueNodata_lbl.Text = datalost_dgv.RowCount.ToString(); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } } else { MessageBox.Show("Hãy chọn đầy đủ thông tin để tiếp tục", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { WarehouseVTListVo inVo = (WarehouseVTListVo)vo; StringBuilder sql = new StringBuilder(); DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append(@"Delete From t_vt_datalost Where "); if (!String.IsNullOrEmpty(inVo.MachineSerial)) { sql.Append(@" machine_serial =:machine_serial"); sqlParameter.AddParameterString("machine_serial", inVo.MachineSerial); } if (!String.IsNullOrEmpty(inVo.RFId)) { sql.Append(@" or rfid =:rfid"); sqlParameter.AddParameterString("rfid", inVo.RFId); } sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); WarehouseVTListVo outVo = new WarehouseVTListVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { WarehouseVTListVo inVo = (WarehouseVTListVo)vo; StringBuilder sql = new StringBuilder(); ValueObjectList <WarehouseVTListVo> voList = new ValueObjectList <WarehouseVTListVo>(); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append(@"select count(*) as counter from t_vt_list_check b left join t_vt_machine a on a.machine_serial = b.machine_serial where 1=1 "); if (!String.IsNullOrEmpty(inVo.MachineSerial)) { sql.Append(@" and b.machine_serial =:machine_serial"); sqlParameter.AddParameterString("machine_serial", inVo.MachineSerial); } if (!String.IsNullOrEmpty(inVo.CheckTime.ToString())) { sql.Append(@" and b.check_time =:check_time"); sqlParameter.AddParameterInteger("check_time", inVo.CheckTime); } if (!String.IsNullOrEmpty(inVo.RFId)) { sql.Append(@" and a.rfid_cd =:rfid_cd"); sqlParameter.AddParameterString("rfid_cd", inVo.RFId); } sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { WarehouseVTListVo outVo = new WarehouseVTListVo { CounterRow = dataReader["counter"].ToString(), }; voList.add(outVo); } dataReader.Close(); return(voList); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { WarehouseVTListVo inVo = (WarehouseVTListVo)vo; StringBuilder sql = new StringBuilder(); ValueObjectList <WarehouseVTListVo> voList = new ValueObjectList <WarehouseVTListVo>(); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append(@"select a.check_id,b.rfid_cd, a.machine_serial, a.check_time,a.registration_user_cd, a.registration_date_time, a.value_last from t_vt_list_check a left join t_vt_machine b on a.machine_serial = b.machine_serial where 1=1 "); if (!String.IsNullOrEmpty(inVo.MachineSerial)) { sql.Append(@" and b.machine_serial =:machine_serial"); sqlParameter.AddParameterString("machine_serial", inVo.MachineSerial); } if (!String.IsNullOrEmpty(inVo.CheckTime.ToString())) { sql.Append(@" and check_time =:check_time"); sqlParameter.AddParameterInteger("check_time", inVo.CheckTime); } sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { WarehouseVTListVo outVo = new WarehouseVTListVo { CheckId = int.Parse(dataReader["check_id"].ToString()), RFId = dataReader["rfid_cd"].ToString(), MachineSerial = dataReader["machine_serial"].ToString(), CheckTime = int.Parse(dataReader["check_time"].ToString()), RegistrationUserCode = dataReader["registration_user_cd"].ToString(), RegistrationDateTime = DateTime.Parse(dataReader["registration_date_time"].ToString()), ValueCheck = bool.Parse(dataReader["value_last"].ToString()), }; voList.add(outVo); } dataReader.Close(); return(voList); }
private void GridBindList() { try { WarehouseVTListVo whvos = new WarehouseVTListVo() { MachineSerial = warehouse_vt_dgv.Rows[0].Cells[7].Value.ToString(), CheckTime = int.Parse(checktime_cmb.Text), }; ValueObjectList <WarehouseVTListVo> listvo = (ValueObjectList <WarehouseVTListVo>)DefaultCbmInvoker.Invoke(new Cbm.SearchMachineListVTCbm(), whvos); warehouse_list_dgv.DataSource = listvo.GetList(); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { WarehouseVTListVo inVo = (WarehouseVTListVo)vo; StringBuilder sql = new StringBuilder(); ValueObjectList <WarehouseVTListVo> voList = new ValueObjectList <WarehouseVTListVo>(); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append(@"select datalost_id, rfid, machine_serial,check_time, command from t_vt_datalost where 1=1 "); sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //check time ??? //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { WarehouseVTListVo outVo = new WarehouseVTListVo { DatalostId = int.Parse(dataReader["datalost_id"].ToString()), RFId = dataReader["rfid"].ToString(), MachineSerial = dataReader["machine_serial"].ToString(), CheckTime = int.Parse(dataReader["check_time"].ToString()), Comment = dataReader["command"].ToString(), }; voList.add(outVo); } dataReader.Close(); return(voList); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { WarehouseVTListVo inVo = (WarehouseVTListVo)vo; StringBuilder sql = new StringBuilder(); sql.Append(@"insert into t_vt_list_check(machine_serial, check_time, registration_user_cd, registration_date_time, value_last) "); sql.Append(@"values(:machine_serial, :check_time , :registration_user_cd , now(), :value_last)"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameter("machine_serial", inVo.MachineSerial); sqlParameter.AddParameter("check_time", inVo.CheckTime); sqlParameter.AddParameter("registration_user_cd", inVo.RegistrationUserCode); sqlParameter.AddParameter("value_last", inVo.ValueCheck); sqlParameter.AddParameter("registration_date_time", inVo.RegistrationDateTime); WarehouseVTListVo outVo = new WarehouseVTListVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
private void ok_btn_Click(object sender, EventArgs e) { if (checkdata()) { checkid_cmb.DataSource = null; CheckId(); if (intcheckid == 0) { WarehouseVTVo outVo = new WarehouseVTVo(); WarehouseVTVo inVo = new WarehouseVTVo() { RFId = rfid_txt.Text, MachineCode = machine_cd_txt.Text, MachineName = machine_name_cmb.Text, MachineQty = int.Parse(qty_txt.Text), MachineModel = model_cmb.Text, MachineSerial = serial_txt.Text, MachineLocation = location_txt.Text, MachineSupplier = machine_supplier_cmb.Text, MachineInvoice = invoice_txt.Text, MachineCostValue = cost_txt.Text, RegistrationUserCode = UserData.GetUserData().UserName, RegistrationDateTime = DateTime.Now, TimeCheck = int.Parse(checktime_txt.Text), MachineStatus = "Máy CTY", }; try { outVo = (WarehouseVTVo)DefaultCbmInvoker.Invoke(new Cbm.AddNewMachineVTCbm(), inVo); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } if (outVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, machine_cd_txt.Text + " : " + machine_cd_txt.Text); logger.Info(messageData); popUpMessage.Information(messageData, Text); //delete trong table datalost WarehouseVTListVo outVo2 = new WarehouseVTListVo(); WarehouseVTListVo inVo2 = new WarehouseVTListVo() { RFId = rfid_txt.Text, MachineSerial = serial_txt.Text, }; try { outVo2 = (WarehouseVTListVo)DefaultCbmInvoker.Invoke(new Cbm.DeleteDatalostVTCbm(), inVo2); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } rfid_txt.Text = ""; serial_txt.Text = ""; } } else if (intcheckid > 0) { MessageBox.Show("RFId hoặc Machine serial đã tồn tại trong danh sách !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void click_btn_Click(object sender, EventArgs e) { warehouse_vt_dgv.DataSource = null; warehouse_list_dgv.Visible = true; warehouse_vt_dgv.Visible = false; datalost_dgv.Visible = false; if (checktime_cmb.SelectedItem != null && (rfid_txt.Text.Length == 10 || machine_serial_cmb.Text != "")) { Countrow(); warehouse_vt_dgv.DataSource = null; GridBind(); if ((warehouse_vt_dgv.Rows.Count == 1) && (insert_update == "Insert")) { warehouse_vt_dgv.Visible = false; WarehouseVTListVo outVo = new WarehouseVTListVo(); WarehouseVTListVo inVo = new WarehouseVTListVo() { MachineSerial = warehouse_vt_dgv.Rows[0].Cells[7].Value.ToString(), ValueCheck = true, CheckTime = int.Parse(checktime_cmb.Text), RegistrationUserCode = UserData.GetUserData().UserName, RegistrationDateTime = DateTime.Now }; try { outVo = (WarehouseVTListVo)DefaultCbmInvoker.Invoke(new Cbm.AddNewListCheckVTCbm(), inVo); warehouse_list_dgv.DataSource = null; GridBindList(); WarehouseVTVo outVo2 = new WarehouseVTVo(); WarehouseVTVo inVo2 = new WarehouseVTVo { MachineSerial = warehouse_vt_dgv.Rows[0].Cells[7].Value.ToString(), //load machine serial TimeCheck = int.Parse(checktime_cmb.Text), }; outVo2 = (WarehouseVTVo)DefaultCbmInvoker.Invoke(new Cbm.UpdateCheckTimeVTCbm(), inVo2); machine_serial_cmb.Text = ""; rfid_txt.Text = ""; // checktime_cmb.Text = ""; } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } warehouse_list_dgv.Visible = true; } //update else if ((warehouse_vt_dgv.Rows.Count == 1) && (insert_update == "Update")) { MessageBox.Show("Máy này đã check với check time lần thứ: " + checktime_cmb.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); GridBindList(); machine_serial_cmb.Text = ""; rfid_txt.Text = ""; // checktime_cmb.Text = ""; } /////////////////////////////// else if (warehouse_vt_dgv.Rows.Count == 0) { WarehouseVTListVo selectedvo = new WarehouseVTListVo { RFId = rfid_txt.Text, MachineSerial = machine_serial_cmb.Text, CheckTime = int.Parse(checktime_cmb.Text), }; machine_serial_cmb.Text = ""; rfid_txt.Text = ""; if (new AddCommentDatalostVT { WareHouseVTListVo = selectedvo, }.ShowDialog() == DialogResult.OK) { GridBind(); } } else if (warehouse_vt_dgv.Rows.Count > 2) { MessageBox.Show("RFId code đang bị trùng hãy xóa bớt 1 dòng trên database rồi dán lại !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Hãy chọn đầy đủ thông tin để tiếp tục", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void timer1_Tick(object sender, EventArgs e) { if (File.Exists(@"D:\VT CP\received.txt")) { string text = System.IO.File.ReadAllText(@"D:\VT CP\received.txt"); rfid_txt.Text = text; //code phan search copy qua { warehouse_vt_dgv.DataSource = null; warehouse_list_dgv.Visible = true; warehouse_vt_dgv.Visible = false; datalost_dgv.Visible = false; if (checktime_cmb.SelectedItem != null && (rfid_txt.Text.Length == 10 || machine_serial_cmb.Text != "")) { Countrow(); warehouse_vt_dgv.DataSource = null; GridBind(); if ((warehouse_vt_dgv.Rows.Count == 1) && (insert_update == "Insert")) { warehouse_vt_dgv.Visible = false; WarehouseVTListVo outVo = new WarehouseVTListVo(); WarehouseVTListVo inVo = new WarehouseVTListVo() { MachineSerial = warehouse_vt_dgv.Rows[0].Cells[7].Value.ToString(), ValueCheck = true, CheckTime = int.Parse(checktime_cmb.Text), RegistrationUserCode = UserData.GetUserData().UserName, RegistrationDateTime = DateTime.Now }; try { outVo = (WarehouseVTListVo)DefaultCbmInvoker.Invoke(new Cbm.AddNewListCheckVTCbm(), inVo); warehouse_list_dgv.DataSource = null; GridBindList(); exporttxtfile(); WarehouseVTVo outVo2 = new WarehouseVTVo(); WarehouseVTVo inVo2 = new WarehouseVTVo { MachineSerial = warehouse_vt_dgv.Rows[0].Cells[7].Value.ToString(), TimeCheck = int.Parse(checktime_cmb.Text), }; outVo2 = (WarehouseVTVo)DefaultCbmInvoker.Invoke(new Cbm.UpdateCheckTimeVTCbm(), inVo2); } catch { string textdatafaile = "May chu bi su co, kiem tra lai chuong trinh may chu"; exporttxtfile_mesger(textdatafaile); } warehouse_list_dgv.Visible = true; } //update else if ((warehouse_vt_dgv.Rows.Count == 1) && (insert_update == "Update")) { string textduplicate = "Data bi trung, da check roi"; exporttxtfile_mesger(textduplicate); } /////////////////////////////// else if (warehouse_vt_dgv.Rows.Count == 0) { string textdatalost = "May nay khong có trong danh sach database"; exporttxtfile_mesger(textdatalost); } else if (warehouse_vt_dgv.Rows.Count > 2) { string textdatafaile = "database sai cau truc, kiem tra lai database"; //sua lai exporttxtfile_mesger(textdatafaile); } } else { string textdatafaile = "Hệ thông có dữ liệu mới, hệ thống đang online"; exporttxtfile_mesger(textdatafaile); } } File.Delete(@"D:\VT CP\received.txt"); } { machine_serial_cmb.Text = ""; rfid_txt.Text = ""; } }