|
Hey budy ,incase if u didnt understand my question, the report is intended to give a daily and monthly report to the company owner to see what kind of items and how much s/he sold.
Thank you.
|
|
|
|
|
Think about a class that creates that information, it's pretty easy. A collection of transactions and add up the cost and income for each one.
WHAT that report is does not matter, you are using a tool that is notoriously labour intensive.
Did you search the CP articles as I suggested? The answer is there for you, choose an approach and impliment it.
If you have a specific problem, then the answer will be more specific.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I've written a code something like this
bool signalled = autoResetEvent.GetActionServerEvent.WaitOne();
if (!signalled)
return "time out";
else
{
}
and when this executes, the thread will block at above first line(as it should) now when I'll call autoResetEvent.Set() it will return true . But what I need to call so that it return a false value ? I tried Reset() but the thread keep blocked.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
The WaitOne() overload always returns true ( or throws an exception ) because it only returns when signalled.
The return bool is used in the other 2 overloads which take a timeout parameter. These can return false if they timeout before being signalled.
BTW, you want to pass false for the mysterious exitContext parameter
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Well, I wanted to cancel the WaitOne . And I've created a class with custom functions...that gonna help me
Here it is :
public class XAutoResetEvent : EventWaitHandle
{
public XAutoResetEvent(bool initialState)
: base(initialState, EventResetMode.AutoReset)
{ }
bool wasCancelled = false;
public void CancelWait()
{
wasCancelled = true;
this.Set();
}
public bool XWaitOne()
{
this.WaitOne();
if (wasCancelled)
{
wasCancelled = false;
return false;
}
else
return true;
}
}
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
The card image has rounded corners instead of square ones. When you drag it around the form it gets the correct transparency in the direction of travel but the direction you came from gets that really cool "whatever was on drawn over me last" effect. I know that the issue is that the pixels behind the control were never drawn to begin with, so there's no data for the transparency. Anyone know of a solution to it?
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
Card cTest = new Card();
cTest.Location = new Point(5, 5);
cTest.CardFace = Properties.Resources.AceClub;
Controls.Add(cTest);
Card cTest2 = new Card();
cTest2.Location = new Point(50, 5);
cTest2.CardFace = Properties.Resources.AceClub;
Controls.Add(cTest2);
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
public partial class Card : UserControl
{
Bitmap _CardFace;
Boolean _bMouseDown = false;
Point _pMouse;
public Bitmap CardFace
{
get { return _CardFace; }
set
{
_CardFace = value;
Width = _CardFace.Width;
Height = _CardFace.Height;
}
}
public Card()
{
InitializeComponent();
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.Opaque, true);
BackColor = Color.Transparent;
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics gGraphics = e.Graphics;
gGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
gGraphics.DrawImage(CardFace, new Point(0, 0));
}
protected override void OnPaintBackground(PaintEventArgs e)
{
}
protected override void OnMouseDown(MouseEventArgs e)
{
_bMouseDown = true;
_pMouse = e.Location;
BringToFront();
}
protected override void OnMouseUp(MouseEventArgs e)
{
_bMouseDown = false;
}
protected override void OnMouseMove(MouseEventArgs e)
{
if (Capture && _bMouseDown)
{
Point P2CP = Parent.PointToClient(Cursor.Position);
Location = new Point(P2CP.X - _pMouse.X, P2CP.Y - _pMouse.Y);
}
}
}
|
|
|
|
|
Try taking a look at this excellent article from here on CP. Per Pixel Alpha Blend in C#[^].
From your description of your problem, it sounds as if this should do the trick.
Good Luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Why can't I get this to display how many answers are correct which are entered by the user? What am I doing wrong? Here's what I have.
using System;
class Drivers_License_Exam
{
static void Main()
{
char[] exArray = new char[] { 'B', 'D', 'A', 'A', 'C', 'A', 'B', 'A', 'C', 'D', 'B', 'C', 'D', 'A', 'D', 'C', 'C', 'B', 'D', 'A' };
char[] userArray = new char[20];
char ansHold;
char[] correct = new char[20];
for (int i = 0; i < userArray.Length; i++)
{
Console.Write("Question #{0}: ", (i + 1));
ansHold = Convert.ToChar(Console.ReadLine());
ansHold = Char.ToUpper(ansHold);
while (ansHold < 'A' || ansHold > 'D')
{
Console.WriteLine("Invalid answer, please enter a letter A through D");
Console.Write("Question #{0}: ", (i + 1));
ansHold = Convert.ToChar(Console.ReadLine());
ansHold = Char.ToUpper(ansHold);
}
userArray[i] = ansHold;
}
TotalCorrect(correct);
}
public static void TotalCorrect(char[] userAnswers)
{
char[] examAnswers = new char[] { 'B', 'D', 'A', 'A', 'C', 'A', 'B', 'A', 'C', 'D', 'B', 'C', 'D', 'A', 'D', 'C', 'C', 'B', 'D', 'A' };
int[] wrongAnswers = new int[20];
int j = 0;
int countCorrect = 0;
for (int i = 0; i < 20; i++)
{
if (userAnswers[i] == examAnswers[i])
{
countCorrect += 1;
}
else
{
wrongAnswers[j] = i + 1;
j++;
}
}
Console.WriteLine("");
Console.WriteLine("There are {0} correct answer(s).", countCorrect);
}
}
|
|
|
|
|
Hi,
seems like you are storing answers in userArray, yet you are checking another array ("correct"), which hasn't been filled at all. So zero is coming out. Test by passing "exArray", should give 20. Then fix by passing userArray.
BTW: your code could be improved a lot; for starters I wouldn't use a char array, I would simply pass a 20-char string (which could be entered as a single line, much faster!).
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Thanks for your input. I'll try it out.
Sorry but I'm just learning C#, which is driving me nuts. (Especially arrays)You are probably right about my code needing improving, but my teacher said that we should use char arrays.(Probably just to teach us the hard way...LOL)
Thanks again, this is only one part of the problem that we have to figure out so I'll keep working on it.
|
|
|
|
|
I Got It, wooohooo!
|
|
|
|
|
Hello.
I m using C# and sql server2005
I want to retrieve values from Datatable but dt kno how to do this.
My code is as follows,it checks from view(since it is the combination of specific columns from 2 tables)that whether the a particular service is reserved for the next day or not:
dtTableRecords_out = null;
string strQueryString = null;
SqlCommand objSqlCommand = null;
SqlConnection objSqlConnection = null;
DataSet objDataSet = null;
SqlDataAdapter objDataAdapter = null;
SqlDataReader objDataReader = null;
string day = (DateTime.Now.AddDays(1).Day.ToString());
string month = (DateTime.Now.Month.ToString());
string year = (DateTime.Now.Year.ToString());
string date_nextDay = month + '/' + day + '/' + year;
try
{
objDataSet = new DataSet();
objDataAdapter = new SqlDataAdapter();
objSqlConnection = new SqlConnection(ConnectionString.GetSQLConnectionString());
strQueryString = "select * from view_reservation where date = " + date_nextDay;
objSqlCommand = new SqlCommand(strQueryString, objSqlConnection);
objDataAdapter.SelectCommand = objSqlCommand;
objSqlConnection.Open();
objDataSet.Clear();
objDataAdapter.Fill(objDataSet);
objSqlConnection.Close();
dtTableRecords_out = objDataSet.Tables[0];
if (strQueryString != null)
{
Console.WriteLine("Service is reserved for tommorow");
}
else
{
Console.WriteLine("no reervation");
}
}
finally
{
if (objSqlConnection.State == ConnectionState.Open)
{
objSqlConnection.Close();
}
}
return strQueryString;
}
but the if statement is not executiong correctly.
I want the result(eg service_name or customer_id) from the query for further processing.
Hope that u ppl will provide me with an answer.I am sorry i forgot to put my code inside code block
|
|
|
|
|
I think that you have made an error in your if condition. How can strQueryString be null ? Just a few lines above you set it to "select * from view_reservation where date = " + date_nextDay; , and you never reset it!
From a very quick look at your code I suspect that what you need is something like:
if (dtTableRecords_out.Rows.Count > 0)
{
Console.WriteLine("Service is reserved for tommorow");
}
else
{
Console.WriteLine("no reervation");
}
Two other things that might make your code better/more secure. Please research the using construct, this will enable you to do things like:
using (objSqlConnection = new SqlConnection(ConnectionString.GetSQLConnectionString()))
{
strQueryString = "select * from view_reservation where date = " + date_nextDay;
objSqlCommand = new SqlCommand(strQueryString, objSqlConnection);
objDataAdapter.SelectCommand = objSqlCommand;
objSqlConnection.Open();
objDataSet.Clear();
objDataAdapter.Fill(objDataSet);
objSqlConnection.Close();
}
Using using ensures that objSqlConnection gets closed and disposed, guaranteed, regardless of exceptions or any other problem short of a power-cut.
Also research using parameterized queries Building SQL statements the way you are currently doing, is prone to all sorts of malicious exploits.
Good Luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
thankyou people 4 ur interest
Yes i usually use parameter classes for sql queries.I will use that here after the correct operation of my code.
I have also tried the code of what u suggested but still output is incorerct.Although whenever i execute the query in sql it returns me some rows.
I have also tried with SqlDataReader but DataReader remains null
|
|
|
|
|
1. if your using .net 3.5 then use linq to sql here -> http://www.asp.net/learn/linq-videos/
2. why are you checking wherewer the strQueryString is null or nott why whuld that mather your outputting to dtTableRecords_out the first element of objDataSet.Tables[0] isent that what your going for.
|
|
|
|
|
i have a datagridview that loads a total of 1000 rows from sqlserver. when i click a button to preview the contents of the datagridview to be printed, it only prints 20 rows (those that fit in the datagridview in the form). i want to be able to print ALL the data that is loaded into the datagridview. can someone help me with the codes? thank you..
|
|
|
|
|
You need to write code to handle the print event and render ALL the data, not the current page. The stuff you get for free just prints the current screen.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello,
I am trying to programatically add an Image to a word document. I have managed to do that with the code below. However, I need to insert it into a specific cell in a table that is in the document header. I can insert it into a table in the main body, but cant figure out how to set the range to a cell in a table in the header. Any help will be appreciated.
Thank you.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office;
using Word = Microsoft.Office.Interop.Word;
using Microsoft.Office.Interop.Word;
namespace InsertImageIntoWord
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
object missing = System.Reflection.Missing.Value;
object fileName = @"C:\Form100.doc";
ApplicationClass WordApp = new ApplicationClass();
Document odoc = WordApp.Documents.Open(ref fileName, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
WordApp.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader;
Range rng = odoc.Tables[1].Cell(1, 3).Range;
rng.InlineShapes.AddPicture(@"C:\Test.jpg", ref missing, ref missing, ref missing);
WordApp.Visible = true;
}
}
}
|
|
|
|
|
Did you get any help. I am facing same issue.
|
|
|
|
|
Hi.
Above code works fine but I want to insert image at the beginning of existing word document.Please provide me the solution.
|
|
|
|
|
ApplicationClass WordApp = new ApplicationClass();
The above code is not working..
I am getting the below error.
Microsoft.Office.lnterop.Word.ApplicationClass cannot be embedded. Use the applicable interface instead.
|
|
|
|
|
Hello,
I searched all over the internet but didn't find a very good answer on this. I know this is a very helpful forum so maybe I will get lucky.
The question is pretty simple : How can I get the position (x,y) of a small image in a large image ? The ideea is that the large image contains the small image, but I want to find out where exactly it is.
I know it can be done by converting the images to bmp and after that going to each pixel at a time and checking if it exists.
Is there another way ?
Can someone help ?
Thanks
PS: The big image is black and white (not monochrome, but only black and white) and the small image is also only black and white.
modified on Saturday, September 19, 2009 6:59 PM
|
|
|
|
|
sodevrom wrote: Is there another way ?
The simplest method to start with is pretty simple. You pretty much get the pixel from the top left corner of the small image, then start scanning the big image, row-by-row, pixel-by-pixel, looking for a pixel of that color. When you find it, then you start getting each pixel in the small image for the rest of the top row and comparing those to the next pixels in the big image. If they match, you go to the next rows and start comparing those pixels, until your done. If not, go back and keep scanning for the top left corn pixel.
|
|
|
|
|
Hello,
I thought that maybe there is a faster way to do this.
Something like convert the image (this is a stupid idea, but something siliar ) to a string and use seomthing like image.indexof ...
Maybe something to do with bytes .
Any ideas are well appreciated
|
|
|
|
|
Which, when you write that method, would do the exact same thing.
Search the Articles for Christian Graus' Image Processing articles for examples on scanning an image quickly.
|
|
|
|
|