//private bool ValidateInput() //{ // bool result; // message = String.Empty; // if (tbName.Text == "") // { // message += "Name is empty!" + "<br/>"; // } // if (tbDOB.Text == "") // { // message += "DOB is empty!" + "<br/>"; // } // if (tbPhone.Text == "") // { // message += "Phone is empty!" + "<br/>"; // } // if (tbEmail.Text == "") // { // message += "Email is empty!" + "<br/>"; // } // if (tbPassword.Text == "") // { // message += "Password is empty!" + "<br/>"; // } // return string(message); // MessageBox.Show(Message); //} protected void registerbtn_Click(object sender, EventArgs e) { Cust d = new Cust(); int result = d.AddCustomer(tbname.Text, Convert.ToDateTime(tbdob.Text), Convert.ToInt32(tbPhone.Text), tbEmail.Text, tbPassword.Text); Response.Redirect("Login.aspx"); }
public async Task <IActionResult> PutCust(int id, Cust cust) { if (id != cust.Id) { return(BadRequest()); } _context.Entry(cust).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static void BatchCustInfo(DataTable dt, Oper oper) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); foreach (DataRow dr in dt.Rows) { Cust cu = new Cust(dr); cu.cnvcOperID = oper.cnvcOperID; cu.cndOperDate = dtSysTime; //newOper.cndCreateDate = dtSysTime; string strCount = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select count(*) from tbCust where cnnCustID = " + cu.cnnCustID + " or cnvcName='" + cu.cnvcName + "'").ToString(); if (Convert.ToInt32(strCount) > 0) { throw new Exception(cu.cnvcName + "已存在"); } EntityMapping.Create(cu, trans); BusiLog busiLog = new BusiLog(); busiLog.cndOperDate = dtSysTime; busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans); busiLog.cnvcComments = cu.cnvcName; busiLog.cnvcFuncCode = " 批量添加客户档案"; busiLog.cnvcOperID = oper.cnvcOperID; busiLog.cnvcIPAddress = ""; EntityMapping.Create(busiLog, trans); } trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public IHttpActionResult GetCust(int id) { Cust cust = db.Cust.Find(id); if (cust == null) { return(NotFound()); } return(Ok(cust)); }
public IHttpActionResult DeleteCust(int id) { Cust cust = db.Cust.Find(id); if (cust == null) { return(NotFound()); } db.Cust.Remove(cust); db.SaveChanges(); return(Ok(cust)); }