Showing posts from January, 2011

WPF Combobox Selected Index Change

private void cmbPCNo_SelectionChanged(object sender, SelectionChangedEventArgs e)
                string PCName = cmbPCNo.SelectedValue as string;
                txtUserTicket.Text = objTimeManagementManager.GetTicketNoManager(PCName, DateTime.Today);
            catch (Exception ex)
                MessageBox.Show("Error: " + ex.Message, "PC Name", MessageBoxButton.OK, MessageBoxImage.Error);

WPF generate xml file for list view data to save in database.

/**********Generatating XML**********/
            string strEmploymentInfoListObject = "";
            System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(ticket.ListOfTicket.GetType());
            MemoryStream memoryStream = new MemoryStream();
            XmlTextWriter xmlWriter;
            xmlWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
            xmlWriter.Namespaces = true;
            x.Serialize(xmlWriter, ticket.ListOfTicket);
            string xml;
            xml = Encoding.UTF8.GetString(memoryStream.GetBuffer());
            xml = xml.Substring(xml.IndexOf(Convert.ToChar(60)));
            xml = xml.Substring(0, (xml.LastIndexOf(Convert.ToChar(62)) + 1));
            strEmploymentInfoListObject = xml;

            /****** Checking The XML Data is Generate or not ********/


Edit List view control in WPF

Consider the following Class.Mind it that you have to bind the class in list view property.

EPromotion objPromotion =new EPromotion();
objPromotion.EmployeeId = Convert.ToInt64(employeeIdTextBox.Text);
objPromotion.EmployeeName = employeeNameTextBox.Text;
List<EPromotion> liPromotion = new List<EPromotion>();
objPromotion.listPromotion = liPromotion;

/******** ADD ******/

/*** Selected EDIT *****/

EPromotion selectedPromotion = (EPromotion)this.promotionlistView.SelectedItem;

/***** Selected remove *******/

Copy a store procedure from one database to another.

Some times we need to copy a store procedure from one database to another. then we have to follow the following steps:

Right click on the SP under the DB and click Script Stored Procedure As > CREATE To > File, it will create an SQL script file, then run that script on the other database.

It's important that when you execute the store procedure just rename the database name.

Copy a table from one database to another database in SQL

Open a new query window in SQL server Management studio. in which database you want to copy a  table. Type

into new_name_of_table 
from old_database.table_name.

such as:
select* into Appointments from IEMS2.dbo.Appointments