//InSertAllSalesperson private int InSertAllSalesperson(DataTable tb_salesperson) { int result = 0; foreach (DataRow datarow in tb_salesperson.Rows) { if (datarow[0].ToString() != "") { EC_tb_SalesPerson ec_tb_salesperson = new EC_tb_SalesPerson(); ec_tb_salesperson.SalespersonID = Convert.ToInt32(datarow[0].ToString()); ec_tb_salesperson.Name = StaticClass.GeneralClass.HandlingSpecialCharacter(datarow[1].ToString()); ec_tb_salesperson.Birthday = datarow[2].ToString(); ec_tb_salesperson.Address = StaticClass.GeneralClass.HandlingSpecialCharacter(datarow[3].ToString()); ec_tb_salesperson.Email = StaticClass.GeneralClass.HandlingSpecialCharacter(datarow[4].ToString()); ec_tb_salesperson.Password = datarow[5].ToString(); ec_tb_salesperson.Active = Convert.ToInt32(datarow[6].ToString()); ec_tb_salesperson.Defaul = Convert.ToInt32(datarow[7].ToString()); if (bus_tb_salesperson.InsertSalesPerson(ec_tb_salesperson, StaticClass.GeneralClass.flag_database_type_general) == 1) { result++; } } } return(result); }
//muiBtnOK_Click private void muiBtnOK_Click(object sender, RoutedEventArgs e) { if (txbName.Text == "") { tblNotification.Text = FindResource("name_null").ToString(); txbName.Focus(); return; } if (pwbPassword.Password.Trim() == "") { tblNotification.Text = FindResource("password_null").ToString(); pwbPassword.Focus(); return; } else { try { EC_tb_SalesPerson ec_tb_salesperson = new EC_tb_SalesPerson(); //ec_tb_salesperson.SalespersonID = bus_tb_salesperson.GetMaxSalespersonID("") + 1; ec_tb_salesperson.Name = StaticClass.GeneralClass.HandlingSpecialCharacter(txbName.Text); ec_tb_salesperson.Birthday = dtpBirthday.Text; ec_tb_salesperson.Address = StaticClass.GeneralClass.HandlingSpecialCharacter(txbAddress.Text); ec_tb_salesperson.Email = StaticClass.GeneralClass.HandlingSpecialCharacter(txbEmail.Text); ec_tb_salesperson.Password = StaticClass.GeneralClass.MD5Hash(pwbPassword.Password); ec_tb_salesperson.Defaul = 0; if (chkActive.IsChecked == false) { ec_tb_salesperson.Active = 0; } else { ec_tb_salesperson.Active = 1; } if (bus_tb_salesperson.InsertSalesPerson(ec_tb_salesperson, StaticClass.GeneralClass.flag_database_type_general) == 1) { if (muibtnadd_delegate != null) { muibtnadd_delegate(); } this.Close(); } } catch (Exception ex) { tblNotification.Text = ex.Message; } } }