public void TestReadWriteRread() { var stream = new MemoryStream(); var utf8 = new UTF8Encoding(); var message = new Rread((uint)utf8.GetByteCount("test"), utf8.GetBytes("test")) { Tag = 1247 }; var p = new Protocol.Protocol(stream); p.Write(message); stream.Position = 0; var data = new byte[message.Length]; var length = stream.Read(data, 0, (int)message.Length); Assert.That(length, Is.EqualTo(message.Length)); stream.Position = 0; var message2 = (Rread)p.Read(); Assert.That(message, Is.EqualTo(message2)); }
public void QuantityCheckonSales() { string quantitytextbox = Pqty_textbox.Text; if (quantitytextbox == "") { } else { SqlDataReader Rread; string Connect = ConfigurationManager.ConnectionStrings["coonstring"].ToString(); string Qquantity = ""; SqlConnection Connected = new SqlConnection(Connect); Connected.Open(); SqlCommand Command = new SqlCommand("FetchQuantityfromstock", Connected); Command.CommandType = CommandType.StoredProcedure; Command.Parameters.AddWithValue("@itemname", itemauto_textbox.Text); Command.Parameters.AddWithValue("@Batch", Batchnocombobox.Text); // command.ExecuteNonQuery(); Rread = Command.ExecuteReader(); if (Rread.Read()) { Qquantity = Rread["PQty"].ToString(); } Rread.Close(); Connected.Close(); int i = Convert.ToInt32(Qquantity); int j = Convert.ToInt32(quantitytextbox); if (j > i) { Pqty_textbox.Clear(); itemauto_textbox.BackColor = Color.Red; MessageBox.Show("Out Of Stock"); MessageBox.Show("Stock Available:" + Qquantity); } } }
////QUANTITY UPDATE IN STOCK //public void QuantityUpdateINStock() //{ // string itno="";//itemno // SqlDataReader reader_stock; // string stockconnection = ConfigurationManager.ConnectionStrings["coonstring"].ToString(); // SqlConnection stockcon = new SqlConnection(stockconnection); // stockcon.Open(); // SqlCommand commandstock = new SqlCommand("readfromsalesdummyforitemnameandbatch",stockcon); // commandstock.CommandType = CommandType.StoredProcedure; // reader_stock= commandstock.ExecuteReader(); // while(reader_stock.Read()) // { // quantity_UPDATE = reader_stock["Qty"].ToString(); // batch_UPDATE = reader_stock["Batch"].ToString(); // itno = reader_stock["ItemNo"].ToString(); // string QuantityUpdateConnection = ConfigurationManager.ConnectionStrings["coonstring"].ToString(); // // int noitem = Convert.ToInt32(itemno.ToString()); // SqlConnection connection = new SqlConnection(QuantityUpdateConnection); // connection.Open(); // SqlCommand command = new SqlCommand("update_quantity_in_stock", connection); // command.CommandType = CommandType.StoredProcedure; // command.Parameters.AddWithValue("@quantity", quantity_UPDATE.ToString()); // command.Parameters.AddWithValue("@itemno", itno.ToString()); // command.Parameters.AddWithValue("@batch", batch_UPDATE.ToString()); // command.ExecuteNonQuery(); // connection.Close(); // } // reader_stock.Close(); //} //OUT OF STOCK public void Outofstock() { if (itemauto_textbox.Text == "") { } else { string productlimit = ""; // string itemname = itemauto_textbox.Text; string quantity = ""; //FOR FETCHING MIN LEVEL FROM PRODUCT MASTER SqlDataReader read; string connect = ConfigurationManager.ConnectionStrings["coonstring"].ToString(); SqlConnection connected = new SqlConnection(connect); connected.Open(); SqlCommand command = new SqlCommand("fetch_outofstockfromproductmaster", connected); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@itemname", itemauto_textbox.Text); // command.ExecuteNonQuery(); read = command.ExecuteReader(); if (read.Read()) { productlimit = read["MinLevel"].ToString(); } read.Close(); connected.Close(); //FOR FETCHING PRODUCT QUANTITY FROM STOCK SqlDataReader Rread; string Connect = ConfigurationManager.ConnectionStrings["coonstring"].ToString(); SqlConnection Connected = new SqlConnection(Connect); Connected.Open(); SqlCommand Command = new SqlCommand("FetchQuantityfromstock", Connected); Command.CommandType = CommandType.StoredProcedure; Command.Parameters.AddWithValue("@itemname", itemauto_textbox.Text); Command.Parameters.AddWithValue("@Batch", Batchnocombobox.Text); // command.ExecuteNonQuery(); Rread = Command.ExecuteReader(); if (Rread.Read()) { quantity = Rread["PQty"].ToString(); } Rread.Close(); Connected.Close(); int Quantity = Convert.ToInt32(quantity); int ProductLimit = Convert.ToInt32(productlimit.ToString()); if (Quantity >= ProductLimit) { //MessageBox.Show("Available Stock:"+ Quantity); } else { MessageBox.Show("OUT OF STOCK !" + Quantity); itemauto_textbox.BackColor = Color.Red; } } }
public Message Read() { Message message; var bytes = ReadMessage(); var offset = Constants.Bit32Sz; var type = bytes[offset]; switch (type) { case (byte)MessageType.Tversion: message = new Tversion(bytes); break; case (byte)MessageType.Rversion: message = new Rversion(bytes); break; case (byte)MessageType.Tauth: message = new Tauth(bytes); break; case (byte)MessageType.Rauth: message = new Rauth(bytes); break; case (byte)MessageType.Tattach: message = new Tattach(bytes); break; case (byte)MessageType.Rattach: message = new Rattach(bytes); break; case (byte)MessageType.Rerror: message = new Rerror(bytes); break; case (byte)MessageType.Tflush: message = new Tflush(bytes); break; case (byte)MessageType.Rflush: message = new Rflush(bytes); break; case (byte)MessageType.Twalk: message = new Twalk(bytes); break; case (byte)MessageType.Rwalk: message = new Rwalk(bytes); break; case (byte)MessageType.Topen: message = new Topen(bytes); break; case (byte)MessageType.Ropen: message = new Ropen(bytes); break; case (byte)MessageType.Tcreate: message = new Tcreate(bytes); break; case (byte)MessageType.Rcreate: message = new Rcreate(bytes); break; case (byte)MessageType.Tread: message = new Tread(bytes); break; case (byte)MessageType.Rread: message = new Rread(bytes); break; case (byte)MessageType.Twrite: message = new Twrite(bytes); break; case (byte)MessageType.Rwrite: message = new Rwrite(bytes); break; case (byte)MessageType.Tclunk: message = new Tclunk(bytes); break; case (byte)MessageType.Rclunk: message = new Rclunk(bytes); break; case (byte)MessageType.Tremove: message = new Tremove(bytes); break; case (byte)MessageType.Rremove: message = new Rremove(bytes); break; case (byte)MessageType.Tstat: message = new Tstat(bytes); break; case (byte)MessageType.Rstat: message = new Rstat(bytes); break; case (byte)MessageType.Twstat: message = new Twstat(bytes); break; case (byte)MessageType.Rwstat: message = new Rwstat(bytes); break; default: throw new Exception("Unsupported Message Type"); } return(message); }