Exemplo n.º 1
0
        private void insertButton_Click(object sender, RoutedEventArgs e)
        {
            int    i     = 0;
            string datas = "";

            try
            {
                foreach (DataRow row in values.Rows)
                {
                    if (i == 0)
                    {
                        datas = "('" + row[0].ToString() + "','" + row[1].ToString() + "','" + Convert.ToDateTime(row[2].ToString()).ToString("yyyy-MM-dd HH:mm:ss") + "')";
                    }
                    else
                    {
                        datas = datas + ",('" + row[0].ToString() + "','" + row[1].ToString() + "','" + Convert.ToDateTime(row[2].ToString()).ToString("yyyy-MM-dd HH:mm:ss") + "')";
                    }
                    i++;
                }
                string res = DBManager.InsertIntoInsuranceDetails(datas);
                if (!res.Contains("Success"))
                {
                    myMessageBox mm = new myMessageBox("Invalid Data Type Found. Check your data again", "Error", "OK", 1);
                    mm.ShowDialog();

                    // MessageBox.Show("Invalid Data Type Found. Check your data again", "Error Occured", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    myMessageBox mm = new myMessageBox("Data Added Successfully", "Success", "OK", 0);
                    mm.ShowDialog();

                    //MessageBox.Show("Data Added Succesfully", "Successfully Added", MessageBoxButton.OK, MessageBoxImage.Information);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                //
            }
        }