private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { connection.Open(); string selectQuery = "SELECT * FROM floral_shop_db.ex5 WHERE productName = '" + comboBox1.Text + "' "; MySqlCommand command = new MySqlCommand(selectQuery, connection); MySqlDataReader MDR; try { MDR = command.ExecuteReader(); if (MDR.Read()) { textBox3.Text = MDR.GetString("proPrice"); } else { textBox3.Text = ""; comboBox1.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message); } connection.Close(); }
public ActionResult DeleteConfirmed(int id) { MDR mDR = db.MDRs.Find(id); db.MDRs.Remove(mDR); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,AccessionID,BacteriaName,Antibiotics,DeathRate,Enviromental,Adaptability,Genetics,District,History")] MDR mDR) { if (ModelState.IsValid) { db.Entry(mDR).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(mDR)); }
public void TestToString() { Clock clock = new Clock(); TicTok tictok = new TicTok(); tictok.Init(); int TState = 0; AReg areg = new AReg(); TReg treg = new TReg(); BReg breg = new BReg(); CReg creg = new CReg(); IReg ireg = new IReg(); IPort1 port1 = new IPort1(); IPort2 port2 = new IPort2(); MDR mdr = new MDR(); RAM ram = new RAM(); mdr.SetRefToRAM(ref ram); ALU alu = new ALU(ref areg, ref treg); OReg3 oreg3 = new OReg3(ref alu); OReg4 oreg4 = new OReg4(ref alu); HexadecimalDisplay hexadecimalDisplay = new HexadecimalDisplay(ref oreg3); Flag flagReg = new Flag(ref alu); PC pc = new PC(ref flagReg); MAR mar = new MAR(ref ram); SEQ seq = SEQ.Instance(); Wbus.Instance().Value = string.Concat(Enumerable.Repeat('0', 16)); Instruction currentInstruction = new Instruction { OpCode = "ADD B", BinCode = "10000000", TStates = 4, AffectsFlags = true, AddressingMode = AddressingMode.Register, Bytes = 1 }; Frame frame = new Frame(currentInstruction, TState, port1, port2, pc, mar, ram, ram.RAMDump(), mdr, ireg, SEQ.Instance(), Wbus.Instance().Value, areg, alu, flagReg, treg, breg, creg, oreg3, oreg4, hexadecimalDisplay); _ = frame.ToString(); _ = frame.OutputRegister(); }
public Frame(Instruction instruction, int TState, IPort1 ip1, IPort2 ip2, PC pc, MAR mar, RAM ram, List <string> ramContents, MDR mdr, IReg ireg, SEQ seq, string wbus_string, AReg areg, ALU alu, Flag flagReg, TReg treg, BReg breg, CReg creg, OReg3 oreg3, OReg4 oreg4, HexadecimalDisplay hexadecimalDisplay) { InstructionData = instruction; if (InstructionData.OpCode.Contains(',')) { InstructionData.OpCode = InstructionData.OpCode.Replace(",", string.Empty); } this.TState = TState; this.AReg = areg.ToString_Frame_Use(); this.BReg = breg.ToString_Frame_Use(); this.CReg = creg.ToString_Frame_Use(); this.TReg = treg.ToString_Frame_Use(); this.IReg = ireg.ToString_Frame_Use(); // The real ToString() is in use with a substring in it. This is needed for proper operation this.MAR = mar.ToString_Frame_Use(); this.MDR = mdr.RegContent; this.PC = pc.RegContent; this.ALU = alu.ToString(); this.WBus = wbus_string; this.OPort1 = oreg3.ToString_Frame_Use(); this.OPort2 = oreg4.ToString_Frame_Use(); this.HexadecimalDisplay = hexadecimalDisplay.RegContent; this.RAM = ramContents; this.SEQ = seq.ToString(); this.WBus = wbus_string; // I didnt want to mess with the Singleton in the frame, so the value will just be passed as a string this.RAM_Reg = ram.ToString_Frame_Use(); this.Flags = flagReg.RegContent; if (instruction == null) { this.IReg = "???"; } if (TState > 3) { Instruction = InstructionData.OpCode; } else { Instruction = "???"; } }
// GET: MDRs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MDR mDR = db.MDRs.Find(id); if (mDR == null) { return(HttpNotFound()); } return(View(mDR)); }
public double CalculoTaxa(Transacao _transacao) { MDR Mdr = _mdrRepositorio.GetMDR().FirstOrDefault(mdr => mdr.Adquirente == _transacao.Adquirente.ToLower()); Taxa taxa = Mdr.Taxas.FirstOrDefault(_taxa => _taxa.Bandeira == _transacao.Bandeira.ToLower()); if (_transacao.Tipo.ToLower() == "credito") { return(CalculoTaxacredito(_transacao, taxa)); } if (_transacao.Tipo.ToLower() == "debito") { return(CalculoTaxadebito(_transacao, taxa)); } return(0); }
public double CalcularTaxa(Transacao _transacao) { MDR Mdr = _mdrRepository.RetornarMDR().FirstOrDefault(mdr => mdr.Adquirente[mdr.Adquirente.Length - 1] == _transacao.Adquirente); Taxa taxa = Mdr.Taxas.FirstOrDefault(_taxa => _taxa.Bandeira == _transacao.Bandeira); if (_transacao.Tipo == "Credito") { return(CalcularTaxaCredito(_transacao, taxa)); } if (_transacao.Tipo == "Debito") { return(CalcularTaxaDebito(_transacao, taxa)); } return(0); }
private void button3_Click(object sender, EventArgs e) { if (textBox3.Text == "")//validating the name textbox { textBox3.BackColor = Color.LightPink; MessageBox.Show("Name is Required", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox3.Focus(); return; } connection.Open(); string selectQuery = "SELECT * FROM floral_shop_db.ex1 WHERE name = '" + textBox3.Text + "' "; MySqlCommand command = new MySqlCommand(selectQuery, connection); MySqlDataReader MDR; try { MDR = command.ExecuteReader(); if (MDR.Read()) { textBox2.Text = MDR.GetString("email"); textBox1.Text = MDR.GetString("addr"); } else { textBox3.Text = ""; textBox2.Text = ""; textBox1.Text = ""; MessageBox.Show("you are not logged in"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } connection.Close(); }
// ************************************************************************* // ************************************************************************* // Engine Runtime // ************************************************************************* public void Run() { Clock clock = new Clock(); TicTok tictok = new TicTok(); tictok.Init(); AReg areg = new AReg(); TReg treg = new TReg(); BReg breg = new BReg(); CReg creg = new CReg(); IReg ireg = new IReg(); IPort1 iport1 = new IPort1(); IPort2 iport2 = new IPort2(); MDR mdr = new MDR(); RAM ram = new RAM(); mdr.SetRefToRAM(ref ram); ALU alu = new ALU(ref areg, ref treg); areg.SetALUReference(ref alu); breg.SetALUReference(ref alu); creg.SetALUReference(ref alu); OReg3 oreg3 = new OReg3(ref alu); OReg4 oreg4 = new OReg4(ref alu); HexadecimalDisplay hexadecimalDisplay = new HexadecimalDisplay(ref oreg3); Flag flagReg = new Flag(ref alu); PC pc = new PC(ref flagReg); MAR mar = new MAR(ref ram); SEQ seq = SEQ.Instance(); Wbus.Instance().Value = string.Concat(Enumerable.Repeat('0', 16)); areg.Subscribe(clock); treg.Subscribe(clock); breg.Subscribe(clock); creg.Subscribe(clock); ireg.Subscribe(clock); mar.Subscribe(clock); pc.Subscribe(clock); alu.Subscribe(clock); // ALU must come after A and T flagReg.Subscribe(clock); ram.Subscribe(clock); mdr.Subscribe(clock); oreg3.Subscribe(clock); hexadecimalDisplay.Subscribe(clock); oreg4.Subscribe(clock); // Load the program into the RAM ram.LoadProgram(Program); // Load the intsructionSet into the SEQ seq.Load(InstructionSet); Frame tempFrame; #region Program_Exec // Since T1-T3 for all of the Intruction is the same, // LDA or "0000" will be used as the intruction for all T1-T3's clock.IsEnabled = true; int max_loop_count = 10_000; int loop_counter = 0; int TState = 1; // A basic empty instruction state with 3 TStates since on the 4th the instruction // will be known and set to a new object reference. Instruction currentInstruction = new Instruction() { OpCode = "???", TStates = 4 // Since by 4 TStates it should know what instruction it is on }; List <string> controlWords = new List <string>(); bool? didntJump = null; while (clock.IsEnabled) { // Log the Instruction if (TState == 4) { currentInstruction = InstructionSet.Instructions.FirstOrDefault(i => i.BinCode.Equals(ireg.RegContent)); seq.LoadBackupControlWords(currentInstruction.MicroCode); string iname = currentInstruction.OpCode; int operandVal = Convert.ToInt32(ireg.RegContent, 2); string hexOperand = "0x" + operandVal.ToString("X"); } if (TState <= 3) { seq.UpdateControlWordReg(TState, "00000000", didntJump); if (didntJump ?? false) { pc.SkipByte(); didntJump = null; } } else { seq.UpdateControlWordReg(TState, ireg.RegContent); } clock.SendTicTok(tictok); tictok.ToggleClockState(); clock.SendTicTok(tictok); tictok.ToggleClockState(); tempFrame = new Frame(currentInstruction, TState, iport1, iport2, pc, mar, ram, ram.RAMDump(), mdr, ireg, SEQ.Instance(), Wbus.Instance().Value, areg, alu, flagReg, treg, breg, creg, oreg3, oreg4, hexadecimalDisplay); _FrameStack.Add(tempFrame); // HLT if (ireg.RegContent.Equals("01110110", StringComparison.Ordinal) && TState == 5) { clock.IsEnabled = false; _RAMDump = ram.RAMDump(); } if (loop_counter >= max_loop_count) { throw new EngineRuntimeException("Engine Error: Infinite Loop Detected"); } else { loop_counter++; } if (TState == 7 && currentInstruction.OpCode.StartsWith('J')) { pc.CheckForJumpCondition(); // PC is going to jump so do not let it fetch the next byte and immediately endx if (!pc.WontJump) { currentInstruction.TStates = 7; didntJump = true; } } if (TState < currentInstruction.TStates) { TState++; } else { TState = 1; currentInstruction = new Instruction() { OpCode = "???", TStates = 4 // Since by 4 TStates it should know what instruction it is on }; } } OutputReg = oreg3.ToString(); #endregion Program_Exec }
public DesafioController(MDR mDR) { this.mDR = mDR; }
public static List <MDR> ListaMDR() { List <MDR> lista = new List <MDR>(); #region AdquirenteA var mdrA = new MDR(); mdrA.Adquirente = Adquirente.A.ToString(); mdrA.Taxas = new List <Taxas>(); Taxas taxa1A = new Taxas(); taxa1A.Bandeira = Bandeira.Visa.ToString(); taxa1A.Credito = 2.25m; taxa1A.Debito = 2.00m; mdrA.Taxas.Add(taxa1A); Taxas taxa2A = new Taxas(); taxa2A.Bandeira = Bandeira.Master.ToString(); taxa2A.Credito = 2.35m; taxa2A.Debito = 1.98m; mdrA.Taxas.Add(taxa2A); lista.Add(mdrA); #endregion #region AdquirenteB var mdrB = new MDR(); mdrB.Adquirente = Adquirente.B.ToString(); mdrB.Taxas = new List <Taxas>(); Taxas taxa1B = new Taxas(); taxa1B.Bandeira = Bandeira.Visa.ToString(); taxa1B.Credito = 2.50m; taxa1B.Debito = 2.08m; mdrB.Taxas.Add(taxa1B); Taxas taxa2B = new Taxas(); taxa2B.Bandeira = Bandeira.Master.ToString(); taxa2B.Credito = 2.65m; taxa2B.Debito = 1.75m; mdrB.Taxas.Add(taxa2B); lista.Add(mdrB); #endregion #region AdquirenteC var mdrC = new MDR(); mdrC.Adquirente = Adquirente.C.ToString(); mdrC.Taxas = new List <Taxas>(); Taxas taxa1C = new Taxas(); taxa1C.Bandeira = Bandeira.Visa.ToString(); taxa1C.Credito = 2.75m; taxa1C.Debito = 2.16m; mdrC.Taxas.Add(taxa1C); Taxas taxa2C = new Taxas(); taxa2C.Bandeira = Bandeira.Master.ToString(); taxa2C.Credito = 3.10m; taxa2C.Debito = 1.58m; mdrC.Taxas.Add(taxa2C); lista.Add(mdrC); #endregion return(lista); }