-->

Sunday, April 20, 2014

Doctor Medicine Prescription Project in Windows Forms with C#

Download this project

Project cost : 300Rs or $10
Pay me at:
PayPal id : saini1987tarun@gmail.com

Via bank transfer

ICICI bank account number is :    153801503056
Account holder name is :                 Tarun kumar saini
IFSC code is :                                   ICIC0001538

SBBJ bank detail :                             61134658849
Account holder name:                        Tarun kumar saini
IFSC code :                                        SBBJ0010398

CONTACT ME

narenkumar851@gmail.com

Doctor Medicine Prescription system covers the functionality to store the symptoms of the patient’s disease date by date and also the medicines written by the doctor. It is windows form project which may be a setup file to be installed in client’s system.


Features of the project:


  • Only authorized person can login into the system and use the software.
  • User can add/modify patients, disease and medicines which will stored in the database.
  • Through this system, all the symptoms of particular disease and their medicines may be stored in the database according to date.
  • Small project to be installed in the windows platform.

System Requirements:


  • Visual studio 2010 or higher
  • SqlServer 2008 or higher
  • DotNet Framework 4.0 or higher(pre-loaded with visual studio)

Run the Project:

It is a windows form application, so either press F5 or click on Start button. It will load the login window, which requires username and password. Username is “admin” and password is “password”, click on login button and the manage options window will be shown to you.

Project’s Functions:

Manage List: here all the functions of project can be redirected through a single click.

1. Manage list doctor medicine project

Manage Patient: where user can add/modify all the details about a patient like name, father name, age, address, contact no and also registration date.

2. Manage patient in doctor medicine project

Manage Disease: user can add/modify details about diseases like their name and type.

Manage Symptoms: there are some symptoms of particular disease which should be first stored in the system. It also have related medicine details for each symptoms, which may be prescribed to the patient.

Manage Medicine: where user can add/modify all the details about medicines like their name, type, the salt contains and components including in the medicine.

Prescribe medicine: user can assign the medicines to particular patient according to their symptoms/disease. By a single click the system will store the medicines assigned to the patient.

3. prescribe form doctor medicine project

The coding part is so simple of this project so that other programmer can easily change the functionality as per the requirements.

How to Serve Files to User in Asp.Net MVC

Let the user download a file from server is not a typical task, programmer have to write some lines of code which will execute the task. Asp.Net MVC action with returning type FileResult will complete this task in few task listed in the article.

After uploading file/files on the server, how to deliver/serve a file for user to download and save on an individual system depends on the way of storing the file on the server by programmer. Programmer can provide a simple link to an action including some lines of code to perform the task.

In the controller write below line of c# code in the action named “DownloadFile” which will access the file saved on the root of this project and then prompt user to Open/Save that file.

public FileResult DownloadFile()
{
var file = Server.MapPath("~/download file.txt");
return File(file, "Text", "download file");
}

These two line of code will sufficient to prompt the user, now in view page create an actionline which will redirect the user to this action. The second line of code will creates a System.Web.Mvc.FilePathResult object by using the file name, the content type, and the file download name.

@Html.ActionLink("Download File", "DownloadFile");

Run the project and particular controller/action then click on the link created above. This will show an opening download file window having two option to open or save that file, as shown in the below image:

How to Serve Files to User in Asp.Net MVC

Saturday, April 19, 2014

How to Validate File or File type in Java Script MVC

Programmer need to check whether the file is selected by the user or not, when uploading a file. If user will not upload any file and submit the form, the code will throw an exception with description like "file must not be null".

To overcome this issue programmer have to check the uploaded file before the form submission, and this can be performed by using Java script. Write the following code in our view where the file upload control is placed:

function validateForm() {
if ($("#file").val() == "") {
alert("Please select a file");
return false;
}
}

Here “#file” is the id of file upload control and we are checking the value of this control. If the value is empty then it will alert with the message shown and return back to the form. If this control will have file then it will submit the form. On the submit button, just call this function to execute this code with Onclick=”validateForm();”.

Now to select only some file types write another function as below:

function checkfile(sender) {
        var validExts = new Array(".jpeg", ".jpg", ".png");
        var fileExt = sender.value;
        fileExt = fileExt.substring(fileExt.lastIndexOf('.'));
        if (validExts.indexOf(fileExt) < 0) {
            alert("File must of types \".jpeg\", \".jpg\", \".png\");
            $("#file").val('');
            return false;
        }
        else return true;
    }

This function will be called on OnChange event of the file upload control. It will show an alert message written above if the type of selected file will not be in the list declared in the function. Write CheckFile(this) in onChange event of the file upload control.

In this function we are checking only the extension of the selected file, extension may be found by any individual logic. Earlier article was about to uploading file, this java script will not submit the form if user will not select any file through the file upload control.

How to Upload File/Files in Asp.Net MVC

Uploading a file is need some Html code with setting the encoding type to multipart/form-data and the method of form is post. After setting this type, programmer have to use file upload control having the property name and id. Here is the code written in the view page:

@using (Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <div>
        <input type="file" name="file" id="file"/>
</div>
<input type="submit" value="Upload" />
}

This code will place a file upload control to browse a single file of any type of extension and a submit button which will help to post this file to action. Now our action method must have a specific parameter written below in the code:

public ActionResult GetValues(HttpPostedFileBase file)
{
var fileName = System.IO.Path.GetFileName(file.FileName);
var path = System.IO.Path.Combine(Server.MapPath("Path/"), fileName);
file.SaveAs(path);
…………
………..

In this action method programmer can easily get this file and can save this file as done in above code. This code is for uploading/accessing single file, what if programmer want to upload multiple files.

To upload multiple files in view page, just change the file upload control as written below:

<input type="file" name="files" id="files" multiple/>

In the action method of controller change the parameter as written below:

public ActionResult GetValues(IEnumerable<HttpPostedFileBase> files)
{
foreach (var file in files)
{

}
……..
……..
All the files can easily accessed and using the foreach loop, programmer can perform individual action with these files. If programmer want to limit the no. of files to be uploaded by the user, no. of file upload control can be used in the view page and action code will remain same as is.

What if two files are uploaded with the same name, the previous file will be overwritten by the new one. To overcome with these issues we can rename the file when we are saving them like unique identifier or may be other unique name. Programmer can also perform some validation discussed earlier.

How to get last index of 2D array in c# ASP.NET

Suppose you have 2D array in the form of x and y axis, You want to access last index of both axis. Now at this time, you can consider x as row and y as column. Here we use GetUpperBound ( ) method for accessing last index of array. Lets take an example, in which we will pass 0 and 1 in the GetUpperBound ( ) method. Here 0 for first axis and 1 for second axis.
<form id="form1" runat="server">
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Clike"
        BackColor="#99CCFF" />
    <div>
   
        <asp:Label ID="Label1" runat="server" BackColor="Yellow"></asp:Label>
   
    </div>
    </form>

Code Behind
protected void Button1_Click(object sender, EventArgs e)
    {
        {
            string[,] fruits = new string[4, 2]
        {
            {"Red","Apple"},
            {"Orange","Orange"},
            {"Yellow","Banana"},
            {"Green","Mango"},          
        };
            int rows = fruits.GetUpperBound(0);            
            int columns = fruits.GetUpperBound(1);
            Label1.Text = "index of last element of first dimension [0] in fruits array: " + rows.ToString();
            Label1.Text += "<br />index of last element of second dimension [1] in fruits array: " + columns.ToString();
            Label1.Text += "<br /><br />two dimension fruits array elements.........<br />";
            for (int currentRow = 0; currentRow <= rows; currentRow++)
            {
                for (int currentColumn = 0; currentColumn <= columns; currentColumn++)
                {
                    Label1.Text += fruits[currentRow, currentColumn] + " ";
                }
                Label1.Text += "<br />";
            }
        }
Code Generate the following output
How to get last index of 2D array in c# ASP.NET


Friday, April 18, 2014

Add weeks in existing date ASP.NET example

Introduction

Using Add Days method  you can add weeks in integer (converts weeks in days), Object will be updated with new date. This method is used where you want to calculate date after some days. Like Library management project. Lets take an simple example

<form id="form1" runat="server">
    <asp:Button ID="Button1"
    runat="server"
    BackColor="#99CCFF"
    onclick="Button1_Click"
    Text="Click" />
    <div>  
    <asp:Label ID="Label1"
    runat="server"
    BackColor="Yellow"></asp:Label>  
    </div>
    </form>
Code Behind 
protected void Button1_Click(object sender, EventArgs e)
        {        
            DateTime today = DateTime.Today;        
            DateTime after2week = today.AddDays(14);            
            DateTime after4weeks = today.AddDays(28);
            Label1.Text = "today= " + today.ToLongDateString();
            Label1.Text += "<br /><br />after added two weeks with today=";
            Label1.Text += after2week.ToLongDateString();
            Label1.Text += "<br /><br />after added 4 weeks with today=";
            Label1.Text += after4weeks.ToLongDateString();

        }
Code generate the following code

Add weeks in existing date ASP.NET example

Add days in existing date ASP.NET example

Introduction

Using AddDays method  you can add Days in integer, Object will be updated with new date. This method is used where you want to calculate date after some days. Like Library management project. Lets take an simple example
<form id="form1" runat="server">
    <div>  
        <asp:Button ID="Button1"
        runat="server"
        BackColor="#66CCFF"
        onclick="Button1_Click" Text="Click" />  
    </div>
        <asp:Label ID="Label1"
        runat="server"
        BackColor="Yellow"></asp:Label>
    </form>
Code Behind-
protected void Button1_Click(object sender, EventArgs e)
        {          
            DateTime today = DateTime.Today;
            DateTime after2Days = today.AddDays(2);
            Label1.Text = "today= " + today.ToLongDateString();
            Label1.Text += "<br /><br />after added 2 days with today= ";
            Label1.Text += after2Days.ToLongDateString();

        }  
OutPut-


Add days in existing date ASP.NET example

© Copyright 2013 Computer Programming | All Right Reserved