tim_gunning
Posts
-
DataGridView Sorting Problem -
SSIS and stored procedureshi all I was wondering if anyone could help, I need to pass 2 variables to a stored procedure that in turn fires off an SSIS job that calls a stored procedure.... (dont ask!). I can get the variables into the stored procedure no problem, but getting them through to the job is proving harder than I would expect. I can set static params through the Set Values option but cannot see a way of making them dynamic ?> any thought greatly appreciated ta
-
How to place user controls dynamically on a windows formunless I'm missing the point entirely wouldnt it be something along these lines:
yourControl.Left = Convert.ToInt32(yourXPosTextBox.Text);
yourControl.Top = Convert.ToInt32(yourYPosTextBox.Text);or at least thats how I position controls within a form, if you mean something else ginore me :)
-
getting directory list in creation date orderi would use something like
string fileName = "/path/to/your/file";
DateTime dt = File.GetCreationTime(fileName);and then work with the returned date depending on how you wanted to order it. have a look at this for some pointers http://stackoverflow.com/questions/844251/how-to-sort-arraylist-of-datetime-objects-in-descending-order[^]
-
Default character sets for fonts and foreign charactershi all I seem to have run into a problem and was wondering if anyone else had seen someting similar or could point me in the right direction. I have an application that displays user inputted text in a choice of fonts (they choose). However when somebody inputs cyrillic text it doesnt show into the correct font (AbbeyRoad NF) but displays it in Arial. I thought this was because I set a default font face and then try to reset as the chosen one but this isnt the case, as AbbeyRoadNF doesnt have the cyrillic char set in it I'm assuming its defaulting to Arial internally but I can't see where this is happening as its not throwing any errors and I need to catch where this happens so I can alter the font for the print processing (which doesnt default to Arial). has anyone heard of anything like this ? Any thoughts at all welcome. thanks tim
-
GridView ?hi all i have a little question for you all. I have a series of panels that are created dynamically in my main form (this is a windows exe) and they all have different attributes that can be assigned to them (unknown amount of attributes, they're assigned dynamically and manually) and what I was wondering was what would be the best way to display them. I was thinking of using a GridView. Basically what I want to do is have a list of attributes and associated values that are also editable. Is a gridview the best way forward or should I be thinking of something else? All thoughts appreciated, thanks tim
-
PictureBox Control Arrayshi greeg thanks for that, that worked out just fine, what I actually wanted to do was control from within the PictureBoxArray.cs and not from the button_Click, but I just did a little method in there and it ow swaps the colours depending on which one you click on which is perfect for me. thank you again tim
-
PictureBox Control ArraysHi all i've created a Form (Form1.cs) and Control Array handler (PictureBoxArray.cs) which all works fine but my problem is I want to be able to access the *clicked on* picturebox but it doesn't seem to be working, well I cant make it work is a bit more truthful. I'm sure its fairly simple but I can't work out a way of doing it and now I've been looking so long I'm kind of blinded by it! I have this in my PictureBoxArray.cs
private void pictureBox\_MouseDown(object sender, MouseEventArgs e) { System.Windows.Forms.MessageBox.Show("You have clicked button " + ((System.Windows.Forms.PictureBox) sender).Tag.ToString()); }
but but from here I can't do things like change the background colour, if I put a button into the main form (Form1) and do a :
public void button2\_Click(object sender, System.EventArgs e) { pictureBoxArray\[0\].BackColor = Color.Red; }
then it works fine but I want to be able to change the colour of the one I clicked on so I need to know which one it is (does that make sense ?) I folowed the msdn guide on creating the control array here http://msdn.microsoft.com/en-us/library/aa289500(VS.71).aspx[^] I sure it is probably fairly simple but like i said I've just lost it now ! thanks in advance for any help tim
-
MySQL to MSSQL conversion of stmtcheers tim that helped a lot,i've been looking at this (migration overall) for about a week now and i can't really see the trees for the woods anymore, my brains withered. ta tim
-
MySQL to MSSQL conversion of stmthi tim problem is...I dont want to do anything with them apart from get the values in the same way you do in MySQL, I just want to get rid of the duplicates that get pulled based on certain criteria. this is what I'm converting:
SELECT
'PI' as transaction_type,
supplier_codes.supplier_code,
supplier_codes.nominal_code,
COUNT(o.orderline_id) as sale_volume,
IF ( EXTRACT(MONTH FROM STR_TO_DATE(CONCAT(YEARWEEK(dispatch_date),'0'),'%x%v%w')) = MONTH(dispatch_date),
DATE_FORMAT(STR_TO_DATE(CONCAT(YEARWEEK(dispatch_date),'0'),'%x%v%w'),'%d/%m/%Y'),
DATE_FORMAT(STR_TO_DATE(CONCAT('01/',EXTRACT(MONTH FROM dispatch_date),'/',YEAR(dispatch_date)),'%d/%m/%Y'),'%d/%m/%Y')) as my_dispatch_date,resource.name as resourcename,
resource.reference,
SUM(supplier_codes.license_fee) as royalty_amount,
tax_codes.code,
ROUND(((SUM(supplier_codes.license_fee) / 100) * tax_codes.multiplier),2) as tax_amount,
"1" as blank_field_2,
"_" as blank_field_3,
"_" as blank_field_4FROM order_line o
LEFT JOIN resource ON o.resource_id = resource.resource_id
LEFT JOIN supplier_codes ON resource.reference = supplier_codes.reference
LEFT JOIN partners ON supplier_codes.partner_id = partners.partner_id
LEFT JOIN partner_type ON supplier_codes.partner_type_id = partner_type.partner_type_id
LEFT JOIN tax_codes ON partners.tax_code = tax_codes.idWHERE supplier_codes.payment_start_date <= dispatch_date
AND supplier_codes.payment_end_date >= dispatch_date
AND o.status = 1
AND DATE_FORMAT(o.dispatch_date,'%Y-%m-%d') >= '$from'
AND DATE_FORMAT(o.dispatch_date,'%Y-%m-%d') < '$to'
AND o.dm !='ZX'GROUP BY reference, supplier_code, my_dispatch_date
ORDER BY dispatch_date, referencedont worry about the difference in some of the vars in it, its only the group by thats doing my head in
-
MySQL to MSSQL conversion of stmthi all im converting a load of queries from MySQL to MSSQL and have run into a problem and was wondering if anyone had any ideas..... I currently have:
SELECT 'PI' AS transaction_type, t1.supplier_code, t1.nominal_code, '01-01-2006' AS my_dispatch_date, t2.name AS resourcename, t2.reference, '1.20' AS royalty_amount,
t3.code, '1.21' AS tax_amount, '1' AS blank_field_2, '_' AS blank_field_3, '_' AS blank_field_4
FROM order_line AS t4 INNER JOIN
resource AS t2 ON t4.resource_id = t2.resource_id INNER JOIN
supplier_codes AS t1 ON t2.reference = t1.reference AND t4.dispatch_date >= t1.payment_start_date AND t4.dispatch_date <= t1.payment_end_date INNER JOIN
partners AS t5 ON t1.partner_id = t5.partner_id INNER JOIN
tax_codes AS t3 ON t5.tax_code = t3.id INNER JOIN
partner_type AS t6 ON t1.partner_type_id = t6.partner_type_id
WHERE (t4.status = 1) AND (t4.dm <> 'ZX') AND (t4.dispatch_date >= @from) AND (t4.dispatch_date <= @to)
ORDER BY t4.dispatch_date, t2.referencebut i need to group by t1.reference, t1.supplier_code but obviously it keeps telling me I can't do that, my brains a bit fried atm, if anyones got any great ideas it would be really helpful ta tim
-
String.fromCharCode and charCodeAthi originally I wss using UTF8 but the js wasnt coping and then I realised chars were missing from the c# end (anything over 127 or so) which I needed (long story....;p) anyway to cut it short I've encoded the js to UTF8 and the c# and then both to base64, used StringBuilder to create my return string and both the js in the flash and c# are producing identical results which is what I needed, I'll post it up here at some point as it may be of interest to someone. thanks for all your help/pointers guffa, very much appreciated. tim
-
String.fromCharCode and charCodeAthi in c# i used
Convert.ToBase64String(Encoding.ASCII.GetBytes(my_str))
and in js i used the base64 encoding i found in amongst the encryption files from http://labs.boulevart.be/index.php/2007/05/23/encryption-in-as2-and-as3/[^] which is where my problems began.... not that i'm putting down what they have there, I just couldn't get it to produce the same results from my end with the rijndael/TEa encryption, the base64 seems to be fine tim edit: this is the function that encodes to base64 in js:
\*/ private static var base64chars:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; /\*\* \* Encodes a base64 string. \*/ public static function encode(src:String):String { var i:Number = 0; var output:String = new String(""); var chr1:Number, chr2:Number, chr3:Number; var enc1:Number, enc2:Number, enc3:Number, enc4:Number; while (i < src.length) { chr1 = src.charCodeAt(i++); chr2 = src.charCodeAt(i++); chr3 = src.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if(isNaN(chr2)) enc3 = enc4 = 64; else if(isNaN(chr3)) enc4 = 64; output += base64chars.charAt(enc1)+base64chars.charAt(enc2); output += base64chars.charAt(enc3)+base64chars.charAt(enc4) } return output; }
-
String.fromCharCode and charCodeAthi thanks for that, thats very interesting and something I didn't realise. but... strangely enough that must be the way that javascript handles it (i think *gulp*) as the original way I was doing it : c#
my_str += (char)(letters[c] ^ keys[cc]);
produces exactly the same result as: js
my_str += String.fromCharCode((src.charCodeAt(c) ^ keys[cc]));
which was(after to base64 encoding for transport(the unencoded isn't really printable)):
OhFBBxQWEBFLGgsEHgoVRBwSEAYCCw==
and yours produced:
OhhBBh4eCRNPEQkMBQQVVRgaHggBBQ==
I was doing this as an little encryption thing between flash and .net as i couldn't find anything that was compatible, I tried many different ones (rijndael, TEA etc) but all the flash conversions of them produced completely different results from the c# end and I was tearing my hair out trying to do my own conversions of them so I thought i would write a simple (obviously not that strong - but it doesnt need to be super difficult) bit of encryption that i could rewrite in javascript(for the .as files in flash and also for php etc) that would suffice. but... like you say the larger the string then the larger the problem(or at least load) so now i'm wondering if theres a way to reproduce what you've said in js - this isn't a problem for what I'm doing now but it would be nice to have a better model in place for future. something for me over the weekend ;) thanks for your replies and if you have any thoughts I'd be really interested to hear them. tim i suppose in js i would just create an array and then use push to add them in and then create the string...but i still don't get why it produces different results from what *should* be the same string...hmmmm time for some script outputting...
modified on Friday, July 4, 2008 8:33 PM
-
String.fromCharCode and charCodeAthi guffa whats the difference between creating an array(then string) or building the string as we go. I dont mean that in a rude way ;) I'm intrigued as they produce two different results from what *should* be the same string or is it the char creation that differs the result ? tim
-
String.fromCharCode and charCodeAtignore ;p was having one of those moments when you cant see the woods for the trees (or whatever!)
my_str += (char)(letters[c] ^ keys[cc]);
does the job after creating the letters array using (Int32)input[i] in a for loop thanks anyway. t
-
String.fromCharCode and charCodeAthi all does anyone know how to convert the following js into c# ?
my_str += String.fromCharCode((src.charCodeAt(c) ^ keys[cc]));
which is contained in the following loop (for clarity):
for(var c:Number = 0; c < src.length; c ++){
if(cc>=i) {
cc = 0;
}
my_str += String.fromCharCode((src.charCodeAt(c) ^ keys[cc]));
cc++;
}I've searched and found the equivalent for both but dont seem to be able to put it together, it should be something like this in c#:
my_str += new String(new char[]{(Int32)Data[c] ^ keys[cc]});
but that obviously fails and im just confusing myself now. any pointer very very much appreciated. keys is already converted into an array of ASCII codes and Data is a string at present, i was thinking I should convert it into an array of ASCII codes as well..... thank you tim
-
layers (?)hi all does anyone know if anything similar to layers exist in the windows api ? I did ask in another forum a while back and was pointed in the direction of nested splitcontainers by brady, but having played with these they don't really do what I'm after and having thought about it I probably do need something more like layers. When I've written web based tools like this I use layers, where you can create a new layer, resize it and move it around the work area whilst maintaining each of their individual x/y & w/h. That has worked well for me and I would like to try and translate this into a windows app but I can't seem to find anything like layers. Sorry if this sounds confused (but I am a little ;p) tia for any advice/pointers tim
-
box or line ?hi brady sorry, i suppose that might have helped....doh! SplitContainer controls sound exactly like the thing I was after, I knew there'd be something rather than me bodging in some sort of tawdry effort that only kind of half works. thanks for the pointer tim
-
box or line ?morning all (or afternoon/evening depending where you are....) I'm not sure if this is the right place to ask, I think it is, but feel free to move it mr(s) admin if need to be to somewhere more appropriate. I was really just after peoples thoughts, so here goes....If I have a page/area divided up into subareas but these are changeable in size what would be the best way to do it? I was thinking originally about just drawing lines (having the x/y of the start point and the length), but then throught its not really the line I'm interested in but the area it encloses so I suppose I would want to be able to draw boxes (similar to divs in a webpage is the best way of decribing it, its basically for laying out information within the application but allowing the user to resize areas) so I would need x/y and w/h. Would that be a more sensible approach ? Or ...(and heres hoping ;) is there something already within the windows api that would handle this - some sort of table type structure would probably do it, just so long as i could return the values of each of the cells. Could I do something with multiple panels maybe, I'd need to maintain the coords etc of them but at least that would give me something *physical* to work with, suppose I should go and play around a bit and see what comes of it. anyway, like I said it was really just to see if anyone thought I was barking up the wrong tree, had completely missed something that was out there or thought maybe i was going in the right direction. cheers tim