Skip to main content

Posts

Showing posts from January, 2011

WPF Combobox Selected Index Change

private void cmbPCNo_SelectionChanged(object sender, SelectionChangedEventArgs e)         {             try             {                 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);             xmlWriter.Close();             memoryStream.Close();             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 ********/                         MessageBox.Show(strE

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>(); liPromotion.Add(objPromotion); objPromotion.listPromotion = liPromotion; /******** ADD ******/ promotionlistView.Items.Add(objPromotion); /*** Selected EDIT *****/ EPromotion selectedPromotion = (EPromotion)this.promotionlistView.SelectedItem; /***** Selected remove *******/ promotionlistView.Items.RemoveAt(promotionlistView.Items.IndexOf(promotionlistView.SelectedItem));

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.