Saturday 3 December 2016

Friday 5 August 2016

800 stray dogs poisoned to death in Karachi



KARACHI: In the wee hours of Thursday, District Municipal Corporation (DMC), South, poisoned a significant number of stray dogs in Karachi following reports of their rising population in the district.
According to DMC South administrator Muhammad Naeem, more than 800 stray dogs were poisoned to death. He said that he was receiving complaints from the residents regarding the rising number of dogs in the area.
The operation was conducted in the entire District South. He explained that they chose midnight on Thursday, as meat markets are closed on Wednesdays and dogs don’t get anything to eat. The team left pieces of poisoned meat in different streets. “We made sure that no children were nearby,” he said. The corpses of the dogs were later shifted to landfill sites.
Officials estimated the citywide operation that started this
week had culled thousands of strays but did not have a full
accounting for all six city districts. The periodic culling of dogs using poison tablets hidden in chicken meat has drawn criticism from animal rights activists in Pakistan, but another city official, Mohammad Zahid, said it was necessary because packs of strays posed a threat to residents.
Last year, Karachi’s Jinnah Hospital treated 6,500 people
bitten by dogs and this year so far it has seen 3,700 cases,
said Dr Seemin Jamali, head of the emergency room.

     

Tuesday 14 June 2016

Windows Form Application n Calculator Example


Objective:
Windows Form Application
Events
Properties
GUI Programming Techniques(Phases)
Calculation Program Example
Windows Form Application:
Sequential programming model is used by console based applications, in which application starts from a point, performs some input/output, selection or iterative operations and stops to another point.

In event driven programming model, application starts from a point and then it enters a message loop. This message loop monitors different events which may occur on application, application executes different event handlers which are associated with these events.

Introduction to Visual Studio .Net environment:

Visual Studio .Net 2008 programming environment is shown below:






Following windows is visible when we select File  New  Project menu items from main window of visual studio .Net.



Main window of IDE of Visual Studio .Net is shown in following figure, when a template type of Windows Form Based Application is selected.









Following toolbox is used to place different user interface elements on a form for a form based application.














GUI Programming Technique: 
Programming technique for GUI based applications is based on three phases, which are described as follows:
Analysis Phase: Gathering information about problem statement and checking solution which is already exisists and planning which feature should be extended or changed.
Designing Phase: Preparation of Object Property Sheet and Object Activity Sheet documents for application.
Coding/Programming Phase: Development of GUI application in Visual Studio .Net by designing GUI layout from planing phase, then setting properties of GUI elements of application using Object Property Sheet. Further programming for event handler functions is done by using Oject Activity Sheet.

Object Property Sheet: This sheet contains information about properties and their values for different GUI elements for a given GUI screen.


Sr # Control Name Property Value  
1 Label Text Enter 1st value  
Name lblVal1  

Object Activity Sheet: This sheet represents pseudo code of event handler functions which are associated with an event which is caused on a user interface element.


Sr # Control Name Event Pseudo-Code  
1 Button Click Validate all fields that is no will will be left empty.
Show message validate successfully or not.  
 


Calculation Program:

Create an application which inputs two integer type values from user in a text box. There are four button named as ADD, SUB, MUL, DIV which performs addition of two number, subtraction of two numbers, multiplication of two numbers and division of two numbers respectively. And show result in another textbox of read-only property as TRUE. There is another button named as CLEAR which clears all text box values, and EXIT button closes the application.

Solution:

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;

namespace calculationApplication
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtVal1.Text == "")
            {
                MessageBox.Show("Enter value 1");
                txtVal1.Focus();
            }
            else if (txtVal2.Text == "")
            {
                MessageBox.Show("Enter 2nd value");
                txtVal2.Focus();
            }
            else
            {
                int v1, v2, res;
                v1 = int.Parse(txtVal1.Text);
                v2 = int.Parse(txtVal2.Text);
                res = v1 + v2;
                txtRes.Text = res.ToString();
            }
        }

        private void btnSub_Click(object sender, EventArgs e)
        {
            if (txtVal1.Text == "")
            {
                MessageBox.Show("Enter value 1");
                txtVal1.Focus();
            }
            else if (txtVal2.Text == "")
            {
                MessageBox.Show("Enter 2nd value");
                txtVal2.Focus();
            }
            else
            {
                int v1, v2, res;
                v1 = int.Parse(txtVal1.Text);
                v2 = int.Parse(txtVal2.Text);
                res = v1 - v2;
                txtRes.Text = res.ToString();
            }
        }

        private void btnMul_Click(object sender, EventArgs e)
        {
            if (txtVal1.Text == "")
            {
                MessageBox.Show("Enter value 1");
                txtVal1.Focus();
            }
            else if (txtVal2.Text == "")
            {
                MessageBox.Show("Enter 2nd value");
                txtVal2.Focus();
            }
            else
            {
                int v1, v2, res;
                v1 = int.Parse(txtVal1.Text);
                v2 = int.Parse(txtVal2.Text);
                res = v1 * v2;
                txtRes.Text = res.ToString();
            }
        }

        private void btnDiv_Click(object sender, EventArgs e)
        {
            if (txtVal1.Text == "")
            {
                MessageBox.Show("Enter value 1");
                txtVal1.Focus();
            }
            else if (txtVal2.Text == "")
            {
                MessageBox.Show("Enter 2nd value");
                txtVal2.Focus();
            }
            else if (int.Parse(txtVal2.Text) == 0)
            {
                MessageBox.Show("Divide by zero is not allowed");
                txtVal2.Focus();
            }
            else
            {
                int v1, v2, res;
                v1 = int.Parse(txtVal1.Text);
                v2 = int.Parse(txtVal2.Text);
                res = v1 / v2;
                txtRes.Text = res.ToString();
            }
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            txtVal1.Text = string.Empty;
            txtVal2.Text = string.Empty;
            txtRes.Text = string.Empty;
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}

Arrays, Stack, Queue, List in Visual Programming c#


Arrays:
An array in Programing Language can be defined as number of memory locations, each of which can store the same data type and which can be references through the same variable name.
An array is a collective name given to a group of similar quantities. These similar quantities could be percentage marks of 100 students, number of chairs in home, or salaries of 300 employees or ages of 25 students.
Syntax:
DATATYPE[ ] ARRAYNAME= new DATATYPE[SIZE] ;
Example:
int[] arrayName=new int[10];
Saving Data in an Array:
for (int i = 0; i < 10; i++)
      {
         arrayName[i] = int.Parse(Console.ReadLine());
      }
Reterving Data from an Array:
for (int i = 0; i < 10; i++)
      {
        Console.WriteLine(arrayName[i]);
      }
Fuctions and Properties Associated with Arrays:
int noOfElement=arrayName.Length;
            int maxValue=arrayName.Max<int>();
            int minValue = arrayName.Min<int>();
            bool flag=arrayName.Contains(10);

STACK:
Working principle is FIRST IN LAST OUT.
Required namespace is : System.Collections.Generic;
To add value in stack push() method is used. To remove from stack pop() method is used. To show top element peek() method is used.
C# Code:

Stack<string> myStack = new Stack<string>();
            myStack.Push("Element 1");
            myStack.Push("Element 2");
            string top=myStack.Peek();
            Console.WriteLine(top);
            Console.WriteLine(myStack.Pop());
            Console.WriteLine(myStack.Pop());
            myStack.Count();
            top = myStack.Peek();
            Console.WriteLine(top);

QUEUE:
Working principle is FIRST IN FIRST OUT.
Required namespace is: System.Collections.Generic;
Too add value in queue enqueue() method is used. To remove from queue dequeue() method is used. To show front element peek() method is used.
C# Code:
Queue<string> myQueue = new Queue<string>();
            myQueue.Enqueue("E1");
            myQueue.Peek();
            myQueue.Dequeue();
            myQueue.Count();
            myQueue.Contains("e1");

LIST:
Required namespace is: System.Collections.Generic;

List<string> newList = new List<string>();
            newList.Add("This");
            newList.Add(" is ");
            newList.Add("my first ");
            newList.Add("application ");
            newList.Add("for Generics");

            foreach (string item in newList)
            {
                Console.WriteLine(item);
            }

            //newList.Clear();
            bool find=newList.Contains(" is ");
            Console.WriteLine(find);

            int noOfItem=newList.Count();
            Console.WriteLine(noOfItem);

            string element=newList.ElementAt(4);
            Console.WriteLine(element);

            newList.Remove("This");

            newList.RemoveAt(0);

            newList.Reverse();