|
It looks like you're trying to do the calculation outside the SUM aggregation but it isn't included in the GROUP BY clause.
Try something like
SELECT TABHDBHCT.MAVACH_SP,
TABHDBHCT.TENSP,
SUM(TABHDBHCT.SOLUONG * CASE WHEN [TRAHANG] = 0 THEN 1 ELSE -1 END) AS SL
...
|
|
|
|
|
Running OK, Thank you very much
|
|
|
|
|
How to set the password in setup file
|
|
|
|
|
|
I use a property grid to set and display a button's properties, I want to get the file name when I changed the button's background image. how to override the click event when click the open button of a popup file selection diaolg?
|
|
|
|
|
|
I can't save any changes to the text file settings.txt , but reading the file works.
The code is
private async void LedShow_Loaded(object sender, RoutedEventArgs e)
{
var path = @"settings.txt";
var folder = Windows.ApplicationModel.Package.Current.Installed Location;
var file = await folder.GetFileAsync(path);
var lines = await Windows.Storage.FileIO.ReadLinesAsync(file);
sliderDelay.Value = Convert.ToInt32(lines[0]);
textBlockDelayValue.Text = lines[0] + " seconds";
buttonSave.IsEnabled = false;
}
and the error message is
An exception of type 'System.UnauthorizedAccessException' occurred in System.Private.CoreLib.dll but was not handled in user code
Access is denied. (Excep_FromHResult 0x80070005) occurred
Can someone help me?
|
|
|
|
|
This would be right. A program normally does not have rights to write to the Program Files folder. In order to do so, you will need to elevate the rights of the application and gain administrative privileges.
The recommendation would be to use the AppData folder. Your best option would be to try and read the file from that location, and if not there, then copy it from the program files folder. Then you can read and write the file to your heart's content.
Cheers,
Mick
------------------------------------------------
It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.
|
|
|
|
|
I can not compress.I will be mad.I am not good in c#.This is my senior project.Please any body contact with me.İf you want help me please write maila address and ı will send mail my problem with my project
|
|
|
|
|
Yeah, that's not going to happen. Nobody is going to do your work for you.
The entire point behind this project is to demonstrate what YOU have learned over these courses, not what begging skills you have.
|
|
|
|
|
Now I need to know how to compress bmp image with huffman if you dont help me why do you write ?
|
|
|
|
|
Because that's NOT what your "question" said. All it said was "send me your email address...". THAT isn't going to happen.
Why do you need someone to do your research for you? There is a ton of information on the web about compressing data with Huffman. All you have to do is Google for "compress data with huffman" and you'll find everything you need.
|
|
|
|
|
Still you repeat same things!!!!!!!!!!
I know huffman algorithm ı also coded huffman algorithm .But
BMP is image ı dont have any information about image.AL info about text.
|
|
|
|
|
If you REALLY knew Huffman, you'd know that you can use it no differently to compress the bytes from ANY file as easily as you feed Text bytes to it.
|
|
|
|
|
ı know huffman ı reliazed with c# for text but image is problem for me?image int not as text ?
|
|
|
|
|
You've been given EVERYTHING you need to fix this yourself, REPEATEDLY, and yet you insist on ignoring that.
We're not the ones with the problem.
|
|
|
|
|
|
Because you dont know how to help !
|
|
|
|
|
Rıza Berkay Ayçelebi wrote: how to help
You can't help someone that refuses to listen to what people tell them.
Speed of sound - 1100 ft/sec
Speed of light - 186,000 mi/sec
Speed of stupid - instantaneous.
|
|
|
|
|
I can send you my project .I knwo huffman ı coded this algorithm.But ı didnt compress BMP could you show me how ı can compress bmp file
|
|
|
|
|
Rıza Berkay Ayçelebi wrote: I can send you my project
Ah ha! Now it makes some sort of sense. You have mistaken us for some "do my homework assignment for me" web site. No, we are not here to do your work for you. You would need to go to a web site where you can hire a programmer to do your work for you.
Speed of sound - 1100 ft/sec
Speed of light - 186,000 mi/sec
Speed of stupid - instantaneous.
|
|
|
|
|
just you can show me for image why dont want help me
|
|
|
|
|
Because the code is EXACTLY the same! You say you've already coded it. There really wouldn't be any significant change, other than how you treat the source data you're passing into the algorithm. You're probably treating everything as a char when you should be treating everything as a byte .
modified 24-Nov-16 14:24pm.
|
|
|
|
|
Here is Choose file for txt files
private void CompressDosyaAc_button_Click(object sender, EventArgs e)
{
try
{
saveFileDialog1.Filter = "Huffman Files (*.huf)|*.huf";
openFileDialog1.Filter = "Text Files (*.txt)|*.txt";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
int[] freq = new int[128];
StreamReader sr = new StreamReader(openFileDialog1.FileName);
iCount = 0;
while (!sr.EndOfStream)
{
int ch = sr.Read();
if (ch >= 0 && ch <= 127)
freq[ch]++;
else
{
MessageBox.Show("Dosya ASCII içerikli değil!", "HATA",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
iCount++;
}
sr.Close();
charFreq = new List<CharFreq>(128);
for (int i = 0; i < 128; i++)
{
if (freq[i] != 0)
{
CharFreq cf = new CharFreq();
cf.ch = (char)i;
cf.freq = freq[i];
charFreq.Add(cf);
}
}
Compress();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "HATA",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
}
Here is compress function ?
<pre lang="c#"> private void
Compress()
{
int bitLength = 0, block = 0, bpBlock = 0;
HuffmanTree ht = new HuffmanTree();
BinaryTreeNode<CharFreq> root = ht.Build(charFreq, charFreq.Count);
leafNodes = 0;
textBox1.Text += ("The Huffman ağacı geçişi\r\n\r\n");
InorderTraversal(root);
if (leafNodes != charFreq.Count)
{
MessageBox.Show("Sıkıştırma ağacı sıkıştırma işleminde hata", "HATA!",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
textBox1.Text += ("Toplam girilen karakter sayısı = " + iCount.ToString() + "\r\n");
textBox1.Text += ("Toplam yaprak kısmındaki karakter sayısı= " + leafNodes.ToString() + "\r\n");
if (leafNodes < 2)
{
bitLength = 1;
block = 8;
bpBlock = 1;
}
else if (leafNodes < 4)
{
bitLength = 2;
block = 4;
bpBlock = 1;
}
else if (leafNodes < 8)
{
bitLength = 3;
block = 8;
bpBlock = 3;
}
else if (leafNodes < 16)
{
bitLength = 4;
block = 2;
bpBlock = 1;
}
else if (leafNodes < 32)
{
bitLength = 5;
block = 8;
bpBlock = 5;
}
else if (leafNodes < 64)
{
bitLength = 6;
block = 4;
bpBlock = 3;
}
else if (leafNodes < 128)
{
bitLength = 7;
block = 8;
bpBlock = 8;
}
int number = (leafNodes * bitLength) / block;
int numberBits = bitLength * iCount;
int numberBlocks = numberBits / (8 * bpBlock);
int remainder = numberBits % (8 * bpBlock);
header = new Header();
header.inputFileLength = iCount;
header.outputDataLength = numberBlocks * bpBlock + remainder / bitLength;
header.tableLength = leafNodes;
header.bitLength = bitLength;
header.chars = new byte[leafNodes];
textBox1.Text += ("Toplam veri miktarı = " + header.outputDataLength.ToString() + "\r\n");
textBox1.Text += ("Toplam bit uzunluğu = " + bitLength.ToString() + "\r\n");
int headerLength = 4 * sizeof(int) + leafNodes * sizeof(byte);
int outputFileLength = headerLength + header.outputDataLength;
double percent = 100.0 - 100.0 * ((double)outputFileLength) / iCount;
textBox1.Text += ("Sıkıştırılmış dosyanın boyutu = " + outputFileLength.ToString() + "\r\n");
textBox1.Text += ("Sıkıştırma Oranı: = %" + percent.ToString("F2"));
aquaGauge1.Value = Convert.ToInt16(percent);
aquaGauge1.ThresholdPercent = Convert.ToInt16(percent);
if (percent <= 0.0)
{
MessageBox.Show("Sıkıştırma oranı 0 veya 0'ın altında oldu,yani sıkıştırma başarız", "HATA!",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
for (int i = 0; i < charFreq.Count; i++)
header.chars[i] = (byte)charFreq[i].ch;
try
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
FileStream fs = new FileStream(saveFileDialog1.FileName,
FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
StreamReader sr = new StreamReader(openFileDialog1.FileName);
byte[] ibuff = new byte[block];
byte[] codes = new byte[block];
bw.Write(header.inputFileLength);
bw.Write(header.tableLength);
bw.Write(header.bitLength);
bw.Write(header.outputDataLength);
bw.Write(header.chars, 0, header.tableLength);
for (int k = 0; k < header.inputFileLength / block; k++)
{
for (int i = 0; i < block; i++)
{
ibuff[i] = (byte)sr.Read();
codes[i] = (byte)255;
for (int j = 0; j < header.tableLength; j++)
{
if (ibuff[i] == header.chars[j])
{
codes[i] = (byte)j;
break;
}
}
if (codes[i] == (byte)255)
{
MessageBox.Show("İşlem başarısız,farklı bir yöntem deneyin", "HATA",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
byte[] obuff = new byte[bpBlock];
for (int i = 0; i < block; i++)
{
int c = (int)codes[i];
for (int j = 0; j < bitLength; j++)
{
int bit = (c >> (bitLength - j - 1)) & 1;
SetBit(i * bitLength + j, bit, obuff);
}
}
bw.Write(obuff, 0, bpBlock);
}
if (header.inputFileLength % block != 0)
{
for (int i = 0; i < header.inputFileLength % block; i++)
{
byte ch = (byte)sr.Read();
bw.Write(ch);
}
}
bw.Flush();
sr.Close();
bw.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "HATA",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
|
|
|
|
|
See, you treat EVERYTHING in the file as a character (integer) in the range of 0 to 127. Change it so you treat everything as a BYTE, that has a range of 0 to 255, LIKE WE'VE BEEN TELLING YOU FOR F***ING DAYS NOW!
|
|
|
|