protected void btnCommit_Click(object sender, EventArgs e) { if (ViewState["Client"] != null) { ClientInfoEntiy entity = (ClientInfoEntiy)ViewState["Client"]; entity.Contact = txtContact.Text.Trim(); entity.Address = txtAddress.Text.Trim(); entity.PID = txtPID.Text.Trim(); entity.PKey = txtKey.Text.Trim(); entity.AlipayAccount = txtAlipayAccount.Text.Trim(); HYCashierDAL.CahierMgrDAL dal = new HYCashierDAL.CahierMgrDAL(); if (dal.UpdateClient(entity)) { Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "customJs", "alert('修改成功'); window.parent.closeDialog();", true); //ScriptManager.RegisterStartupScript(this, typeof(Page), "customJs", "alert('修改成功'); window.parent.closeDialog();", true); } else { Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "customJs", "alert('修改失败,请重试');", true); //ScriptManager.RegisterStartupScript(this, typeof(Page), "customJs", "修改失败,请重试", true); } } else { Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "customJs", "alert('系统错误,请重试');", true); //ScriptManager.RegisterStartupScript(this, typeof(Page), "customJs", "系统错误,请重试", true); } }
public bool AddClient(ClientInfoEntiy clientInfo) { bool flag = false; string sql = "insert into clientInfo (clientid,clientName,phone,contact,address,maxnum,activecode,createtime,status) values('"; sql += clientInfo.ClientID + "','" + clientInfo.ClientName + "','" + clientInfo.Phone + "','" + clientInfo.Contact + "','" + clientInfo.Address + "'," + clientInfo.MaxNum + ",'" + clientInfo.ActiveCode + "',now()," + clientInfo.Status + ")"; flag = DbHelper.ExecuteNonQuery(sql) > 0; return(flag); }
public bool UpdateClient(ClientInfoEntiy clientInfo) { bool flag = false; string sql = "update clientinfo set clientName='" + clientInfo.ClientName + "',phone='" + clientInfo.Phone + @"',contact='" + clientInfo.Contact + "',AlipayAccount='" + clientInfo.AlipayAccount + "',address='" + clientInfo.Address + "',maxnum=" + clientInfo.MaxNum + ",ActiveCode='" + clientInfo.ActiveCode + "' ,updatetime=now(),status=" + clientInfo.Status + ",pid='" + clientInfo.PID + "',pkey='" + clientInfo.PKey + "' where clientid='" + clientInfo.ClientID + "'"; flag = DbHelper.ExecuteNonQuery(sql) > 0; return(flag); }
void AddNewClient() { HYCashierDAL.CahierMgrDAL dal = new CahierMgrDAL(); string name = txtName.Text.Trim(); if (dal.IsClientExist(name)) { ScriptManager.RegisterStartupScript(this, typeof(Page), "customJs", "alert('商户名已存在');", true); return; } string id = dal.GetClientID(); string contact = txtContact.Text.Trim(); string address = txtAddress.Text.Trim(); string activeCode = HYCashierDAL.CryptographyHelper.MD5Encrypt(id + DateTime.Now.ToString("yyyyMMddHHmm")); ClientInfoEntiy entity = new ClientInfoEntiy(); entity.Address = address; entity.PID = txtPID.Text.Trim(); entity.PKey = txtKey.Text.Trim(); entity.ClientID = id; entity.ClientName = name; entity.Contact = contact; entity.MaxNum = 10; entity.ActiveCode = activeCode; entity.AlipayAccount = txtAlipayAccount.Text.Trim(); string js = ""; if (dal.AddClient(entity)) { js = "alert('新增成功'); window.parent.closeDialog();"; } else { js = "alert('新增失败');"; } Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "customJs", js, true); //ScriptManager.RegisterStartupScript(this, typeof(Page), "customJs", js, true); }