protected void rptRule_ItemCommand(object source, RepeaterCommandEventArgs e) { try { if (e.CommandName == "Cancel") { bll.Delete("rule", Convert.ToInt16(e.CommandArgument), CurrentEmployee.EmployeeCode); BindDataList(); } } catch (Exception ex) { JsHelper.AlertOperationFailure(Page, ex); } }
protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(lblID.Text)) { try { WR_Rule model = GetModel(); model.Rule_GUID = Guid.NewGuid(); model.Created_By = CurrentEmployee.EmployeeCode; model.Created_By_Name = CurrentEmployee.EmployeeName; model.Created_On = DateTime.Now; model.Record_Status = 0; bll.Insert(model); List <WR_Attachment> attachements = GetAttachementModel(model.ID); new Attachement().Insert(attachements); JsHelper.AlertOperationSuccessAndRedirect(Page, "RuleList.aspx"); } catch (Exception ex) { JsHelper.AlertOperationFailure(Page, ex); } } else { try { WR_Rule model = GetModel(); model.ID = Convert.ToInt16(lblID.Text); bll.Update(model); new Attachement().DeleteByRuleId(model.ID); List <WR_Attachment> attachements = GetAttachementModel(model.ID); new Attachement().Insert(attachements); JsHelper.AlertOperationSuccessAndRedirect(Page, "RuleList.aspx"); } catch (Exception ex) { JsHelper.AlertOperationFailure(Page, ex); } } }
protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { try { if (e.CommandName == "Delete") { WR_Rule model = new WR_Rule(); model.ID = Convert.ToInt16(e.CommandArgument); model.Record_Status = 2; model.Modified_By = CurrentEmployee.EmployeeCode; model.Modified_By_Name = CurrentEmployee.EmployeeName; model.Modified_On = DateTime.Now; bll.UpdateRecordStatus(model); Label lblCategoryName = (Label)e.Item.FindControl("lblCategoryName"); //删除附件 List <WR_Attachment> items = new Attachement().GetListByRuleId(model.ID); foreach (var item in items) { new Attachement().Delete(item.ID); //删除服务器文件 string path = "/WorkFlowRule/Upload/" + lblCategoryName.Text + "/" + item.FileName; if (File.Exists(Server.MapPath("~" + path))) { File.Delete(Server.MapPath("~" + path)); } } BindDataList(); } if (e.CommandName == "Edit") { Response.Redirect("RuleEdit.aspx?ID=" + e.CommandArgument, false); } } catch (Exception ex) { JsHelper.AlertOperationFailure(Page, ex); } }