protected void btnSubmit_Click(object sender, EventArgs e) { string error = string.Empty; Model.MakeCollectionsModes makecollectionsmode = new Model.MakeCollectionsModes(); makecollectionsmode.Id = this.txtNumber.Text.Trim(); makecollectionsmode.MakeCollectionsMode = this.txtMakeCollectionsMode.Text.Trim(); if (string.IsNullOrEmpty(makecollectionsmode.Id) || string.IsNullOrEmpty(makecollectionsmode.MakeCollectionsMode)) { lbSubmit.Text = "请将带*号的内容填写完整!"; return; } if (MakeCollectionsModeManager.CheckHave(makecollectionsmode.MakeCollectionsMode)) { lbSubmit.Text = "已经有该收款方式,请重新填写!"; return; } else { bool result = false; if (btnSubmit.Text.Equals("添加")) { result = MakeCollectionsModeManager.AddMakeCollectionsMode(makecollectionsmode, ref error); lbSubmit.Text = result == true ? "添加成功!" : "添加失败,原因:" + error; if (result) { Tool.WriteLog(Tool.LogType.Operating, "增加付款方式", "增加成功"); ToolCode.Tool.ResetControl(this.Controls); return; } else { Tool.WriteLog(Tool.LogType.Operating, "增加付款方式", "增加失败!原因" + error); return; } } else { result = MakeCollectionsModeManager.EditMakeCollectionsMode(makecollectionsmode, ref error); lbSubmit.Text = result == true ? "修改成功!" : "修改失败:原因:" + error; if (MakeCollectionsModeManager.EditMakeCollectionsMode(makecollectionsmode, ref error)) { Tool.WriteLog(Tool.LogType.Operating, "编辑付款方式", "编辑失败"); lbSubmit.Text = "修改成功!"; } else { Tool.WriteLog(Tool.LogType.Operating, "编辑付款方式", "编辑失败!原因" + error); lbSubmit.Text = "修改失败!"; return; } } } }
/// <summary> /// 添加收款方式 /// </summary> /// <param name="MakeCollectionsMode">收款方式</param> /// <param name="error"></param> /// <returns></returns> public static bool AddMakeCollectionsMode(Model.MakeCollectionsModes MakeCollectionsMode, ref string error) { if (IsExit(MakeCollectionsMode.Id)) { error = "已存在该编号!请重新填写编号。"; return(false); } if (string.IsNullOrEmpty(MakeCollectionsMode.Id) || string.IsNullOrEmpty(MakeCollectionsMode.MakeCollectionsMode)) { error = "收款方式信息不完整!"; return(false); } string sql = string.Format(@" insert into MakeCollectionsMode (Id,MakeCollectionsMode) values ('{0}','{1}')", MakeCollectionsMode.Id, MakeCollectionsMode.MakeCollectionsMode); return(SqlHelper.ExecuteSql(sql, ref error)); }