Click here to Skip to main content
       

C#

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
AnswerRe: image resizingmvpSandeep Mewara20 Feb '13 - 22:01 
Please be more specific on what have you tried so far and where exactly you are stuck and need help with.
 
Steps:
1. Have image list (list view)
2. Define handler for onclick of list items
3. Have preview panel box displayed
4. Show the item selected with defined height & width in preview panelbox.
Sandeep Mewara
Microsoft ASP.NET MVP 2012 & 2013

[My Blog]: Sandeep Mewara's Tech Journal!
[My Latest Article]: HTML5 Quick Start Web Application

GeneralRe: image resizingmembervimalbala23 Mar '13 - 1:30 
k i wil say clearly..........i hav added an image in panel preview box..it is displayed in list view also......after i made selection in list view...i must move the image with mouse pointer and must resize the image with mouse pointer...............
QuestionC# Money Transfer Question [modified]memberJimmy173420 Feb '13 - 18:10 
Hi, so I'm having trouble with my coding. I've already figured out for to take money from Tom and Rob, but i can't figure out how to deposit that value into the bank. here's what i have so far.
I would really appreciate it if, someone would take a look.
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace Lab05_E00995877
{
public partial class Form1 : Form
{
//Add your form1 variables
Person Tom;
Person Rob;
decimal bank = 50M;
 
public Form1()
{
InitializeComponent();
//Initialize (create) Tom and Rob
Tom = new Person();
Tom.Name = "Joe";
Tom.Cash = 150M;
btnGetOne.Text = "Get from " + Tom.Name;
 

Rob = new Person();
Rob.Name = "Bob";
Rob.Cash = 200M;
btnGetTwo.Text = "Get from " + Rob.Name;
 
UpdateForm();
}
 
public void UpdateForm()
{
lblFirstName.Text = Tom.Name;
lblMoneyOne.Text = Tom.Cash.ToString();
 
lblSecondName.Text = Rob.Name;
lblMoneyTwo.Text = Rob.Cash.ToString();
 
lblMoneyBank.Text = bank.ToString();
}
 
private void btnGetOne_Click(object sender, EventArgs e)
{
decimal decAmount, decTomAmount, decRobAmount, decBankAmount;
try
{
decAmount = Decimal.Parse(txtMoney.Text);
decTomAmount = Decimal.Parse(lblMoneyOne.Text);
decRobAmount = Decimal.Parse(lblMoneyTwo.Text);
decBankAmount = Decimal.Parse(lblMoneyBank.Text);
//bankamount (bank) Amount punched in (decAmount)
if (decTomAmount >= decAmount)
{
decTomAmount -= decAmount;
lblMoneyOne.Text = Tom.ReceiveCash(decAmount).ToString();
lblMoneyBank.Text = bank.ToString();
 

//What do i put here to add to bank after subtracting from Tom?


UpdateForm();
 
}
else
{
MessageBox.Show("Tom doesnt have this many!");
}
txtMoney.Clear();
txtMoney.Focus();
}
catch
{
MessageBox.Show("Please enter numbers only!");
txtMoney.Clear();
txtMoney.Focus();
}
}

private void btnGetTwo_Click(object sender, EventArgs e)
{
 
decimal decAmount, decTomAmount, decRobAmount;
try
{
decAmount = Decimal.Parse(txtMoney.Text);
decTomAmount = Decimal.Parse(lblMoneyOne.Text);
decRobAmount = Decimal.Parse(lblMoneyTwo.Text);
//bankamount (bank) Amount punched in (decAmount)
if (decRobAmount >= decAmount)
{
decRobAmount -= decAmount;
lblMoneyTwo.Text = Rob.ReceiveCash(decAmount).ToString();
lblMoneyBank.Text = bank.ToString();
 
//What do i put here to add to bank after subtracting from Rob?


UpdateForm();
 
}
else
{
MessageBox.Show("Rob doesnt have this many!");
}
txtMoney.Clear();
txtMoney.Focus();
}
catch
{
MessageBox.Show("Please enter numbers only!");
txtMoney.Clear();
txtMoney.Focus();
}
}
}
}
 

 

This is the other part defining the class
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace Lab05_E00995877
{
    class Person
    {
        public string Name;
        public decimal Cash;
        public decimal GiveCash;
 
        public decimal ReceiveCash(decimal amount)
        {
            if (amount > 0)
            {
       //      person       money punched in
                Cash -= amount;
                return Cash;
            }
            else
            {
                MessageBox.Show(amount + "  isnt an amount I'll take",
                    Name + " says..");
                return 0;
            }
        }
    }
}


modified 21 Feb '13 - 0:20.

QuestionRe: C# Money Transfer QuestionmvpEddy Vluggen21 Feb '13 - 8:40 
Jimmy1734 wrote:
//What do i put here to add to bank after subtracting from Tom?
bank += decAmount; 
..but then again, how would you track that it's Toms' money? How much of those 50M belongs to Tom, and how much belongs to Rob?
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

QuestionMD5 hash encrypt and decryptionmemberthekoko8920 Feb '13 - 15:32 
Hi,
i am new in this encoding decoding stufs and i have some problem.
I work on VS 2012 ASP.NET c#.
My problem is that i need to create CheckSum value from some input string. The length of the CheckSum need to be 16 bytes (32 characters) long like this one: "8A303F3E0CB4F8A9CDA5AC120F9B90A4".
The encryption need to be done using a pass key for example TEST_PASS and this key will be used latter to be decrypted this hash value....
hope you understand what i ask and what i need pls help me
GeneralRe: MD5 hash encrypt and decryptionmemberPIEBALDconsult20 Feb '13 - 17:18 
You can hash, but you can't dehash.
AnswerRe: MD5 hash encrypt and decryptionmemberBernhard Hiller20 Feb '13 - 21:12 
Look again at the specs for encryption/decryption. That looks trather like a multistep step procedure:
- user enters password
- system generates salt
- system generates hash from salted password and derives both CheckSum and actual password for encryption
- system stores salt and CheckSum in the encrypted file
- system encrypts input file with the actual password generated above.
When you want to decrypt the file, you can check the password by calculating the CheckSum. The decrpytion algorithm might work with a wrong password too, just producing a nonsense output...
AnswerRe: MD5 hash encrypt and decryptionmvpDave Kreskowiak21 Feb '13 - 2:34 
First, MD5 is a cryptographics HASH, NOT an encryption.
 
Second, it's a ONE-WAY hash. There is no such thing as "decrypting a hash". In theory, you cannot get the original content back from a hash value.
 
Lastly, MD5 is considered broken and should no longer be used in production code. It just doesn't take that much computing power to break it in todays world. Also, two different pieces of content CAN produce the same hash value using MD5!
 
Use something a bit stronger, like SHA512 instead and use proper salting techniques to make it even harder to break.

QuestionPost a file to remote server using HTTPWEBREQUESTmembervanikanc20 Feb '13 - 9:07 
Hello,
 
Below is a piece of code, where in I am trying to post a file from my pc to remote development server. For some reason it does not seem to be working. I don't see the file on the remote server.
 
        private void button2_Click(object sender, EventArgs e)
        {
            FileStream filetoupload = new FileStream("C:\\projects\\testfile.csv", FileMode.Open);
            Uri address = new Uri("http://devsrvr/hints/");
 
            HttpWebRequest webreq = HttpWebRequest.Create(address) as HttpWebRequest;
 
            // set type to post
            webreq.Method = "POST";
            webreq.ContentType = "application/x-www-form-urlencoded";
            webreq.Timeout = 15 * 1000;  
            // data we want to send, which is pretty much a file
                      
            byte[] bytedata = UTF8Encoding.UTF8.GetBytes(filetoupload.ToString());
            webreq.ContentLength = bytedata.Length;
 
            try
            {
                using (Stream poststream = webreq.GetRequestStream())
                {
                    poststream.Write(bytedata, 0, bytedata.Length);
                }
                MessageBox.Show("done!!");
            }
            catch (Exception ex)
            {
                ex.InnerException.ToString();
                ex.Source.ToString();
                ex.Message.ToString();
            }
        }

AnswerRe: Post a file to remote server using HTTPWEBREQUESTmvpEddy Vluggen20 Feb '13 - 9:51 
Change your catch to something like below and try again;
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid