protected void SubmitButton_Click(object sender, EventArgs e) { if (Page.IsValid) { if (memberCard.Pkid == 0) { bll_config.Load(new string[] { "cardNoPwdDigits" }); int cardNoPwdDigits = bll_config.GetInt("cardNoPwdDigits"); if (cardNoPwdDigits <= 0) { WebUtility.ShowAlertMessage("惠卡密码位数必须大于零,请在全局功能中进行设置!", null); } memberCard.Pwd = StringHelper.GetRandomString(cardNoPwdDigits); } if (memberCard.Enabled) { if (StringHelper.IsNumber(AreaId.Value)) { memberCard.CityId = Convert.ToInt32(AreaId.Value); } else { memberCard.CityId = 0; } memberCard.Realname = Realname.Value; memberCard.IdentityCard = IdentityCard.Value; memberCard.PlateNumber = PlateNumber.Value; memberCard.VehicleBrand = VehicleBrand.Value; memberCard.LoadPeople = LoadPeople.Value; memberCard.Mobi = Mobi.Value; memberCard.Email = Email.Value; memberCard.Address = Address.Value; } else { if (CardNo.Value != memberCard.CardNo && bll_memberCard.CardNoExists(CardNo.Value)) { WebUtility.ShowAlertMessage("该卡号已存在,请重新输入!", null); } memberCard.CardNo = CardNo.Value; memberCard.Sold = Sold.Checked; } if (memberCard.Pkid > 0) { //更改 bll_memberCard.Update(memberCard); WebUtility.ShowAlertMessage("保存成功!", "cardManage.aspx" + param); } else { //增加 memberCard.CreateTime = DateTime.Now.ToString(); bll_memberCard.Insert(memberCard); WebUtility.ShowAlertMessage("新增成功!", Request.RawUrl); } } }
private void btnSave_Click(object sender, EventArgs e) { if (G_Status == 0) { G_ListMemberCard = MemberCard.GetAllMemberCard_BySearch(txtCode.Text.Trim(), txtName.Text.Trim(), txtAddress.Text.Trim()); SetDataSource(); RefreshForm(); } else { if (DoValidate()) { if (G_MemberCard.ID > 0) { if (G_MemberCard.Update()) { MessageBox.Show("Cập nhật thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(); RefreshForm(); } else { MessageBox.Show("Cập nhật thất bại", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (G_MemberCard.Insert() > 0) { MessageBox.Show("Thêm mới thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(); RefreshForm(); } else { MessageBox.Show("Thêm mới thất bại", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }