tag:blogger.com,1999:blog-57447312072826505342024-02-20T20:28:57.154-08:00Software Developer HouseBalohttp://www.blogger.com/profile/01550310663502531302noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-5744731207282650534.post-55558579862706688312011-10-28T01:48:00.000-07:002011-10-28T01:48:17.373-07:00Read External Config File in .NETFirst, u must create one file with the extension .config<br />
I named it as Global.config. All the appSettings reside in that file like below:<br />
<br />
<br />
<appSettings><br />
<br />
<add key="LocalDB" value="Data Source=10.23.122.26;Initial Catalog=IMMCFG;uid=jimusr2;pwd=jimusr2"/><br />
<add key="LocalDBP" value="Data Source=10.23.122.25;Initial Catalog=IMMDBP;uid=jimusr2;pwd=jimusr2"/><br />
<add key="JIMDBP" value="Data Source=10.23.122.54;Initial Catalog=JIMDBP;uid=jimusr2;pwd=jimusr2"/><br />
<add key="IMMDBP" value="Data Source=10.23.122.89;Initial Catalog=IMMDBP;uid=jimusr2;pwd=jimusr2"/><br />
<add key="SERVER" value="XPS1640-PC" /><br />
<add key="DB" value="IMMCFG" /><br />
<add key="DB1" value="JIMDBP" /><br />
<add key="DB" value="IMMCFG" /><br />
<add key="DB1" value="JIMDBP" /><br />
<add key="UID" value="sa" /><br />
<add key="PWD" value="password" /><br />
<add key="AppVersion" value="1.2"/><br />
<add key="ClientSettingsProvider.ServiceUri" value="" /><br />
</appSettings><br />
<br />
then, your application config file should look like this:<br />
<br />
<br />
<appSettings file = "../CONFIG/Global.config"><br />
<br />
</appSettings><br />
<br />
<div><br />
</div>Balohttp://www.blogger.com/profile/01550310663502531302noreply@blogger.com0tag:blogger.com,1999:blog-5744731207282650534.post-62561784582595554672011-10-06T02:03:00.000-07:002011-10-06T02:03:31.188-07:00Report Viewer – “More than one data set” ErrorToday I got a best solution to solve <span class="Apple-style-span" style="background-color: white; color: #545454; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 17px;"><b>“More than one data set, data region, or grouping in the report has the name ‘Assembly Name’. Data set, data region, and grouping names must be unique within a report.”</b></span><br />
<span class="Apple-style-span" style="background-color: white; color: #545454; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 17px;"><b><br />
</b></span><br />
<span class="Apple-style-span" style="font-family: Verdana, Helvetica, Arial, sans-serif;"><span class="Apple-style-span" style="font-size: 12px; line-height: 17px;">This error came out </span></span><span class="Apple-style-span" style="background-color: white; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 17px;">due to duplicate data sets in the .rdlc file you created for your report. In my case this occurred when I was using an object data source.</span><br />
<span class="Apple-style-span" style="background-color: white; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 17px;"><br />
</span><br />
<span class="Apple-style-span" style="background-color: white; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 17px;">To solve this error, </span><span class="Apple-style-span" style="background-color: white; color: #545454; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 17px;"> </span><span class="Apple-style-span" style="background-color: white; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 17px;">right-clicking the .rdlc file in the Solution Explorer, selecting Open With, and then XML Editor you’ll be able to see the XML that makes up the report you are designing. By collapsing the “DataSet” elements found within the “DataSets” element you’ll quickly see the duplicates. By expanding the elements back out, scrolling down and finding the “rd:ObjectDataSourceType” element you’ll see what is going on.</span><br />
<span class="Apple-style-span" style="background-color: white; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 17px;"><br />
</span><br />
<span class="Apple-style-span" style="background-color: white; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 17px;">All of this I refer to </span><a href="http://mattgoebel.wordpress.com/2009/03/26/report-viewer-%E2%80%93-%E2%80%9Cmore-than-one-data-set%E2%80%9D-error/">http://mattgoebel.wordpress.com/2009/03/26/report-viewer-%E2%80%93-%E2%80%9Cmore-than-one-data-set%E2%80%9D-error/</a>Balohttp://www.blogger.com/profile/01550310663502531302noreply@blogger.com0tag:blogger.com,1999:blog-5744731207282650534.post-37769414623048153902011-04-27T03:04:00.000-07:002011-04-27T03:04:27.633-07:00How to solve Value cannot be null.Parameter name: activationContextGo to project's properties, then to security and uncheck Enable ClickOnce Security Settings.<br />
Hope this will helpBalohttp://www.blogger.com/profile/01550310663502531302noreply@blogger.com9tag:blogger.com,1999:blog-5744731207282650534.post-80316104315368028732011-04-18T20:52:00.000-07:002011-04-18T20:52:18.566-07:00Auto Update for windows appliction in C#Last week I learn an interesting lesson about using auto update for windows applications.<br />
This auto update will update the application in client computer when the is a new update for the application. This can be done by wyupdate. It is open source. <br />
<br />
All the file can be place in one server, and the client's pc will point into the server to check whether got new update or not. This can be done by autoupdate or user click one update's button.Balohttp://www.blogger.com/profile/01550310663502531302noreply@blogger.com0tag:blogger.com,1999:blog-5744731207282650534.post-79463677466168139872011-04-11T20:41:00.000-07:002011-04-11T20:41:27.855-07:00Database is downArgghhh!!! Today too many table change in the database, so database already down for more than 2 hours. All developers are stuck with their job. Waste lot of time.<br />
<br />
As I heard from my seniors, this is the common situation in project development; table change, database always down, requirement change and etc. So this is the challenge of project development and it is a big project. Many said that we will learn a lot of things if we involve in project development.Balohttp://www.blogger.com/profile/01550310663502531302noreply@blogger.com0tag:blogger.com,1999:blog-5744731207282650534.post-77457463753857770322011-03-30T07:44:00.000-07:002011-03-30T07:44:48.540-07:00Final Year ProjectJust wanna share with u guys about my final year project for my bachelor's degree. My final year project is about GIS (Geographical Information System). The title for this project is Equipment Management System for Paya Indah Wetlands. FYI, Paya Indah Wetlands is one of the recreation park in Malaysia. This system is to manage the schedule the use of equipments in this park using the map. So, here is the main screen for this system. This system I develop using PHP and Advance Javascript.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif2HtRg6ZiYg-K3Gda4X6QvUm1Q8d2ZVwsy63ck0h3z1CvxNtkC0Xg3z1GyaYkqF9KHkAr9sOUo6BI9P3_7IiGsiKPQHtz3aQ5kWxJ1Dw7TTy6I1q23mmmnm0Q36bknnfW99GB03dQumg/s1600/Capture.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="173" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif2HtRg6ZiYg-K3Gda4X6QvUm1Q8d2ZVwsy63ck0h3z1CvxNtkC0Xg3z1GyaYkqF9KHkAr9sOUo6BI9P3_7IiGsiKPQHtz3aQ5kWxJ1Dw7TTy6I1q23mmmnm0Q36bknnfW99GB03dQumg/s320/Capture.PNG" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;">There are 3 users; admin, clerk and staff. This is the login screen for all users. It will differentiate by the role of each user. So here I just put the preview of my screen. Later I will explain more.</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkC-5v3Bk_GaXZxiwQjkzztc9lNSDbgVDmuhW6YDsMlONNQBmddVxLknjAfcnclz9ooqoG8bELLUOUMZ_6aJle21oZcQJ-yDyqwieBwyang7kQSMtsT38C00DtEdIQLEJ-x7A4HNQVeTw/s1600/allEvent.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="211" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkC-5v3Bk_GaXZxiwQjkzztc9lNSDbgVDmuhW6YDsMlONNQBmddVxLknjAfcnclz9ooqoG8bELLUOUMZ_6aJle21oZcQJ-yDyqwieBwyang7kQSMtsT38C00DtEdIQLEJ-x7A4HNQVeTw/s320/allEvent.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: left;"><br />
</div>Balohttp://www.blogger.com/profile/01550310663502531302noreply@blogger.com0tag:blogger.com,1999:blog-5744731207282650534.post-10828481318783653172011-03-29T20:29:00.000-07:002011-03-30T07:09:37.529-07:00Direct printing in C# windows applicationJust wanna share with u all about the direct printing in the C# windows application. This is little bit tricky for me at first because there are so many things about printing in C# that I need to learn. So, here is my code for direct printing. You can design your report in rdlc.<br />
<br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;">private void Print_Click(object sender, EventArgs e)</span><br />
<span class="Apple-style-span" style="font-size: x-small;">{</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>BasePrint printForm = new BasePrint();</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> ReportDataSource reportDataSource = new ReportDataSource();</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> printForm.Report.Reset();</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> printForm.Report.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> reportDataSource.Name = "General_PPT_pptAcception"; <--link to the object for data (the namespace: General.PPT.pptAcception</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> DataTable dt = Util.ConvertDataTable(pptTerima);</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> reportDataSource.Value = dt;</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> ReportViewer ReportViewer = new ReportViewer();</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> ReportViewer.LocalReport.DataSources.Clear();</span><span class="Apple-style-span" style="font-size: x-small;"> </span><br />
<span class="Apple-style-span" style="font-size: x-small;"> </span><br />
<span class="Apple-style-span" style="font-size: x-small;"> ReportViewer.LocalReport.ReportEmbeddedResource = "PrintForm.rdlc";</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> </span><br />
<span class="Apple-style-span" style="font-size: x-small;"> ReportViewer.LocalReport.DataSources.Add(reportDataSource);</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> Export(ReportViewer.LocalReport);</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> Print(Convert.ToInt16(Copy.Text.Trim())); <--number of copy</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;">}</span><br />
<br />
<br />
Also include all this code:<br />
<br />
<br />
<br />
<span class="Apple-style-span" style="font-size: x-small;"> #region direct printing</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> public void Dispose()</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> {</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> if (m_streams != null)</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> {</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> foreach (Stream stream in m_streams)</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> stream.Close();</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> m_streams = null;</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> }</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> }</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> private Stream CreateStream(string name,</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> string fileNameExtension, Encoding encoding,</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> string mimeType, bool willSeek)</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> {</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> Stream stream = new MemoryStream();</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> m_streams.Add(stream);</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> return stream;</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> }</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> // Export the given report as an EMF (Enhanced Metafile) file.</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> private void Export(LocalReport report)</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> {</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> string deviceInfo =</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> @"<DeviceInfo></span><br />
<span class="Apple-style-span" style="font-size: x-small;"> <OutputFormat>EMF</OutputFormat></span><br />
<span class="Apple-style-span" style="font-size: x-small;"> <PageWidth>210mm</PageWidth></span><br />
<span class="Apple-style-span" style="font-size: x-small;"> <PageHeight>280mm</PageHeight></span><br />
<span class="Apple-style-span" style="font-size: x-small;"> <MarginTop>0.1in</MarginTop></span><br />
<span class="Apple-style-span" style="font-size: x-small;"> <MarginLeft>0in</MarginLeft></span><br />
<span class="Apple-style-span" style="font-size: x-small;"> <MarginRight>0in</MarginRight></span><br />
<span class="Apple-style-span" style="font-size: x-small;"> <MarginBottom>0in</MarginBottom></span><br />
<span class="Apple-style-span" style="font-size: x-small;"> </DeviceInfo>";</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> Warning[] warnings;</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> m_streams = new List<Stream>();</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> report.Render("Image", deviceInfo, CreateStream,</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> out warnings);</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> foreach (Stream stream in m_streams)</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> stream.Position = 0;</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> }</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> // Handler for PrintPageEvents</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> private void PrintPage(object sender, PrintPageEventArgs ev)</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> {</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> Metafile pageImage = new</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> Metafile(m_streams[m_currentPageIndex]);</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> // Adjust rectangular area with printer margins.</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> Rectangle adjustedRect = new Rectangle(</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> ev.PageBounds.Left - (int)ev.PageSettings.HardMarginX,</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> ev.PageBounds.Top - (int)ev.PageSettings.HardMarginY,</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> ev.PageBounds.Width,</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> ev.PageBounds.Height);</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> // Draw a white background for the report</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> ev.Graphics.FillRectangle(Brushes.White, adjustedRect);</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> // Draw the report content</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> ev.Graphics.DrawImage(pageImage, adjustedRect);</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> // Prepare for the next page. Make sure we haven't hit the end.</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> m_currentPageIndex++;</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> ev.HasMorePages = (m_currentPageIndex < m_streams.Count);</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> }</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> private void Print(short pages)</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> {</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> if (m_streams == null || m_streams.Count == 0)</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> throw new Exception("Error: no stream to print.");</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> PrintDocument printDoc = new PrintDocument();</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> printDoc.PrinterSettings.Copies = pages;</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> if (!printDoc.PrinterSettings.IsValid)</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> {</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> throw new Exception("Error: cannot find the default printer.");</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> }</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> else</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> {</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> printDoc.PrintPage += new PrintPageEventHandler(PrintPage);</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> m_currentPageIndex = 0;</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> printDoc.Print();</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> }</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> }</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-size: x-small;"> #endregion</span><br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span>Balohttp://www.blogger.com/profile/01550310663502531302noreply@blogger.com1tag:blogger.com,1999:blog-5744731207282650534.post-44388955681156312842011-03-29T10:16:00.000-07:002011-03-30T07:10:57.872-07:00GDI+ error in C# giving me headacheI already spend almost the 3 hours to solve this error for converting the image to string in C#. At last, I already find the solution. I need to store the image from the picture box to image object before converting to string and save it to local first to prevent this GDI+ error. This is my code:<br />
<br />
<span class="Apple-style-span" style="color: blue;"><br />
</span><br />
<span class="Apple-style-span" style="color: blue;"><br />
</span><br />
<span class="Apple-style-span" style="color: blue;">Image imgMAD = pictureBox1.Image;</span><br />
<br />
<span class="Apple-style-span" style="color: blue;"> Bitmap bp = new Bitmap(imgMAD);</span><br />
<span class="Apple-style-span" style="color: blue;"> bp.Save("Image.jpg");</span><br />
<span class="Apple-style-span" style="color: blue;"><br />
</span><br />
<span class="Apple-style-span" style="color: blue;">String strImg = Util.ConvertImageToString("Image.jpg");</span><br />
<span class="Apple-style-span" style="color: blue;"><br />
</span><br />
<span class="Apple-style-span" style="color: blue;">bp.Dispose();</span><br />
<span class="Apple-style-span" style="color: blue;"> </span><br />
<span class="Apple-style-span" style="color: blue;"><br />
</span><br />
<span class="Apple-style-span" style="color: blue;"><br />
</span><br />
<br />
This is the function to convert image to string:<br />
<br />
<br />
<span class="Apple-style-span" style="color: blue;"> public static string ConvertImageToString(string s_ImgPath)</span><br />
<span class="Apple-style-span" style="color: blue;">{</span><br />
<span class="Apple-style-span" style="color: blue;"> Image img = Image.FromFile(s_ImgPath);</span><br />
<span class="Apple-style-span" style="color: blue;"> return Base64ImageToString(img, System.Drawing.Imaging.ImageFormat.Jpeg);</span><br />
<span class="Apple-style-span" style="color: blue;"> }</span>Balohttp://www.blogger.com/profile/01550310663502531302noreply@blogger.com0tag:blogger.com,1999:blog-5744731207282650534.post-11760876352746319842011-03-29T08:46:00.000-07:002011-03-29T09:07:31.436-07:00My career as Software DeveloperHi, this is my first blog after planning to have blog since 3 years ago :)<br />
So, I will just share my experience as Software Developer. I just finish my study in Information System Engineering in local university in Malaysia during June 2010. I start my career in one local software house company since July 2010 as Software Developer. My position require me to use .NET and C# to develop windows application and using Java as middleware to connect with DB2 database. .NET is new for me because during my study, I just familiar with Java, PHP, HTML, CSS and C++. I learn everything myself. Almost all I learn from internet and start develop the simple things first, like GUI using C#.<br />
<br />
Want advise from u all about blogging :)Balohttp://www.blogger.com/profile/01550310663502531302noreply@blogger.com0