private void buttonOK_Click(object sender, EventArgs e) { DateTime nowTime = DateTime.Now; string name = textBox1.Text; string description = textBox2.Text; if (name == "") { MessageBox.Show("姓名不能为空!"); textBox1.SelectAll(); textBox1.Focus(); return; } BaseInfoMemberTester bimt = BaseInfoMemberTester.New; bimt.Name = name; if (description == "") { bimt.Description = "无"; } else { bimt.Description = description; } bimt.PinYin = AutoPinYin.GetPinYin(name); bimt.Mobile = Mobile; bimt.TestDate = nowTime; bimt.FinishedDate = nowTime.AddHours(1); bimt.Status = "0"; bimt.OptrType = UserStatics.OptrType; bimt.Save(); MessageBox.Show("录入完成,请您入园体验!"); this.Close(); }
public static void ImportToAccess(string tableName) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { DataSet ds = new DataSet(); string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + ofd.FileName + ";" + "Extended Properties=Excel 8.0;"; OleDbConnection conn = new OleDbConnection(strConn); conn.Open(); string strExcel = ""; OleDbDataAdapter myCommand = null; strExcel = string.Format("select * from [{0}$]", "Sheet1"); //Sheet1为excel中工作薄 myCommand = new OleDbDataAdapter(strExcel, strConn); myCommand.Fill(ds, "Sheet1"); DataTable dt = ds.Tables["Sheet1"]; for (int iRow = 1; iRow < dt.Rows.Count; iRow++) { BaseInfoMember bifm = BaseInfoMember.New; bifm.CardNumber = dt.Rows[iRow][0].ToString(); bifm.MemberName = dt.Rows[iRow][1].ToString(); bifm.PinYin = AutoPinYin.GetPinYin(bifm.MemberName); bifm.Password = dt.Rows[iRow][3].ToString(); bifm.Birth = (DateTime)dt.Rows[iRow][4]; bifm.Mobile = dt.Rows[iRow][5].ToString(); bifm.Phone = dt.Rows[iRow][6].ToString(); bifm.DiscountRate = (decimal)dt.Rows[iRow][7]; bifm.RemainingSum = (decimal)dt.Rows[iRow][8]; bifm.TotalBonusPoint = (decimal)dt.Rows[iRow][9]; bifm.Frequency = (decimal)dt.Rows[iRow][10]; bifm.TotalSpending = (decimal)dt.Rows[iRow][11]; bifm.Description = dt.Rows[iRow][12].ToString(); bifm.SavedOn = (DateTime)dt.Rows[iRow][13]; bifm.OptrType = UserStatics.OptrType; bifm.Save(); } //DbEntry.Context.UsingConnection(delegate() //{ // IDbBulkCopy c = DbEntry.Context.GetDbBulkCopy(); // c.BatchSize = 10; // c.DestinationTableName = tableName; // c.NotifyAfter = 10; // //c.SqlRowsCopied += new SqlRowsCopiedEventHandler( // // delegate(object sender, SqlRowsCopiedEventArgs e) // // { // // Console.WriteLine("{0} rows copied.", e.RowsCopied); // // }); // c.WriteToServer(dt); //}); } }
private void ctName_TextChanged(object sender, EventArgs e) { ctShortCode.Text = AutoPinYin.GetPinYin(ctName.Text); }
private void ctChildName_TextChanged(object sender, EventArgs e) { ctPinYin.Text = AutoPinYin.GetPinYin(ctChildName.Text); }