/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public int AddRecord(GCalendarArrangeData model) { StringBuilder strSql = new StringBuilder(); strSql.Append("set nocount on; "); strSql.Append("insert into GCalendarArrange("); strSql.Append("remindEmpId,subject,arisesDt,locus,content,aheadRemindMinutes,remindTime,isRead,isDel,isrtEmpId,isrtDt,updtEmpId,updtDt)"); strSql.Append(" values ("); strSql.Append("@remindEmpId,@subject,@arisesDt,@locus,@content,@aheadRemindMinutes,@remindTime,@isRead,@isDel,@isrtEmpId,@isrtDt,@updtEmpId,@updtDt)"); strSql.Append("; select @@identity; set nocount off; "); SqlParameter[] parameters = { new SqlParameter("@remindEmpId", SqlDbType.Int), new SqlParameter("@subject", SqlDbType.NVarChar,50), new SqlParameter("@arisesDt", SqlDbType.DateTime), new SqlParameter("@locus", SqlDbType.NVarChar,50), new SqlParameter("@content", SqlDbType.NVarChar,500), new SqlParameter("@aheadRemindMinutes", SqlDbType.Int), new SqlParameter("@remindTime", SqlDbType.DateTime), new SqlParameter("@isRead", SqlDbType.Bit), new SqlParameter("@isDel", SqlDbType.Bit), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@updtEmpId", SqlDbType.Int), new SqlParameter("@updtDt", SqlDbType.DateTime) }; parameters[0].Value = model.remindEmpId; parameters[1].Value = model.subject; parameters[2].Value = model.arisesDt == string.Empty ? null : model.arisesDt; parameters[3].Value = model.locus; parameters[4].Value = model.content; parameters[5].Value = model.aheadRemindMinutes; parameters[6].Value = model.remindTime == string.Empty ? null : model.remindTime; parameters[7].Value = model.isRead; parameters[8].Value = model.isDel; parameters[9].Value = model.isrtEmpId; parameters[10].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[11].Value = model.updtEmpId; parameters[12].Value = model.updtDt == string.Empty ? null : model.updtDt; int id = 0; try { object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ret != null && ret != DBNull.Value) { id = Convert.ToInt32(ret); } } catch (Exception ex) { throw ex; } return id; }
protected void btnAdd_Click(object sender, EventArgs e) { GCalendarArrangeData model = new GCalendarArrangeData(); GCalendarArrangeBB calendarArrangeBB = new GCalendarArrangeBB(); try { if (this.State == "1") { this.SetModel(ref model); model.isrtDt = DateTime.Now.ToString(); model.isrtEmpId = this.currentUser.empId; model.isDel = false; model.isRead = false; this.IdValue = calendarArrangeBB.AddRecord(model); } else if (this.State == "2") { model = calendarArrangeBB.GetModel(this.IdValue); this.SetModel(ref model); model.updtDt = DateTime.Now.ToString(); model.updtEmpId = this.currentUser.empId; calendarArrangeBB.ModifyRecord(model); } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { calendarArrangeBB.Dispose(); } Response.Redirect("GCalendarArrangeList.aspx?itemNo=" + this.itemNo + "&pTypeNo=main", false); }
//***************************************************************************** //do it later do it later do it later //***************************************************************************** /// <summary> /// ������Ϣ���Ѷ�״̬ /// </summary> /// <param name="runId">��������¼Id</param> public void SetReaded(int arrangeId) { GCalendarArrangeData model = new GCalendarArrangeData(); try { //���¹�������¼״̬ model = this.GetModel(arrangeId); model.isRead = true; this.ModifyRecord(model); } catch (Exception ex) { throw ex; } }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public bool ModifyRecord(GCalendarArrangeData model) { return this.calendarArrangeDB.ModifyRecord(model); }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public int AddRecord(GCalendarArrangeData model) { return this.calendarArrangeDB.AddRecord(model); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { this.BindDateList(); if (Request.Params["id"] != null && Request.Params["id"].Trim() != "") { this.IdValue = Convert.ToInt32(Request.Params["id"]); } if (Request.Params["state"] != null && Request.Params["state"].Trim() != string.Empty) { this.State = Request.Params["state"].ToString(); switch (this.State) { case "1": //add break; case "2": //update //���ؿؼ� GCalendarArrangeBB calendarArrangeBB = new GCalendarArrangeBB(); GCalendarArrangeData calendarArrangeData = new GCalendarArrangeData(); try { calendarArrangeData = calendarArrangeBB.GetModel(this.IdValue); this.ShowInfo(this.IdValue); } finally { calendarArrangeBB.Dispose(); } break; default: break; } } } }
private void SetModel(ref GCalendarArrangeData model) { if (this.remindEmpId.Value != "") { model.remindEmpId = Convert.ToInt32(this.remindEmpId.Value); } else { model.remindEmpId = 0; } model.subject = this.subject.Text; if (this.arisesDt.Text != "") { model.arisesDt = this.arisesDt.Text + " " + this.arisesDtH.SelectedValue + ":" + this.arisesDtM.SelectedValue; } model.locus = this.locus.Text; model.content = this.content.Text; if (this.aheadRemindMinutes.Text != "") { model.aheadRemindMinutes = Convert.ToInt32(this.aheadRemindMinutes.Text); } else { model.aheadRemindMinutes = 0; } if (this.remindTime.Text != "") { model.remindTime = this.remindTime.Text + " " + this.remindTimeH.SelectedValue + ":" + this.remindTimeM.SelectedValue; } }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public bool ModifyRecord(GCalendarArrangeData model) { bool ret = false; StringBuilder strSql = new StringBuilder(); strSql.Append("update GCalendarArrange set "); strSql.Append("remindEmpId=@remindEmpId,"); strSql.Append("subject=@subject,"); strSql.Append("arisesDt=@arisesDt,"); strSql.Append("locus=@locus,"); strSql.Append("content=@content,"); strSql.Append("aheadRemindMinutes=@aheadRemindMinutes,"); strSql.Append("remindTime=@remindTime,"); strSql.Append("isRead=@isRead,"); strSql.Append("isDel=@isDel,"); strSql.Append("isrtEmpId=@isrtEmpId,"); strSql.Append("isrtDt=@isrtDt,"); strSql.Append("updtEmpId=@updtEmpId,"); strSql.Append("updtDt=@updtDt"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@remindEmpId", SqlDbType.Int), new SqlParameter("@subject", SqlDbType.NVarChar,50), new SqlParameter("@arisesDt", SqlDbType.DateTime), new SqlParameter("@locus", SqlDbType.NVarChar,50), new SqlParameter("@content", SqlDbType.NVarChar,500), new SqlParameter("@aheadRemindMinutes", SqlDbType.Int), new SqlParameter("@remindTime", SqlDbType.DateTime), new SqlParameter("@isRead", SqlDbType.Bit), new SqlParameter("@isDel", SqlDbType.Bit), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@updtEmpId", SqlDbType.Int), new SqlParameter("@updtDt", SqlDbType.DateTime) }; parameters[0].Value = model.id; parameters[1].Value = model.remindEmpId; parameters[2].Value = model.subject; parameters[3].Value = model.arisesDt == string.Empty ? null : model.arisesDt; parameters[4].Value = model.locus; parameters[5].Value = model.content; parameters[6].Value = model.aheadRemindMinutes; parameters[7].Value = model.remindTime == string.Empty ? null : model.remindTime; parameters[8].Value = model.isRead; parameters[9].Value = model.isDel; parameters[10].Value = model.isrtEmpId; parameters[11].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[12].Value = model.updtEmpId; parameters[13].Value = model.updtDt == string.Empty ? null : model.updtDt; try { SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); ret = true; } catch (Exception ex) { throw ex; } return ret; }
/// <summary> /// �õ�һ��model /// </summary> /// <param name="id">����ֵ</param> /// <returns>model</returns> public GCalendarArrangeData GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from GCalendarArrange"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int) }; parameters[0].Value = id; GCalendarArrangeData model = new GCalendarArrangeData(); DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; if (row["id"] != DBNull.Value) { model.id = Convert.ToInt32(row["id"]); } if (row["remindEmpId"] != DBNull.Value) { model.remindEmpId = Convert.ToInt32(row["remindEmpId"]); } if (row["subject"] != DBNull.Value) { model.subject = Convert.ToString(row["subject"]); } if (row["arisesDt"] != DBNull.Value) { model.arisesDt = Convert.ToString(row["arisesDt"]); } if (row["locus"] != DBNull.Value) { model.locus = Convert.ToString(row["locus"]); } if (row["content"] != DBNull.Value) { model.content = Convert.ToString(row["content"]); } if (row["aheadRemindMinutes"] != DBNull.Value) { model.aheadRemindMinutes = Convert.ToInt32(row["aheadRemindMinutes"]); } if (row["remindTime"] != DBNull.Value) { model.remindTime = Convert.ToString(row["remindTime"]); } if (row["isRead"] != DBNull.Value) { model.isRead = Convert.ToBoolean(row["isRead"]); } if (row["isDel"] != DBNull.Value) { model.isDel = Convert.ToBoolean(row["isDel"]); } if (row["isrtEmpId"] != DBNull.Value) { model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]); } if (row["isrtDt"] != DBNull.Value) { model.isrtDt = Convert.ToString(row["isrtDt"]); } if (row["updtEmpId"] != DBNull.Value) { model.updtEmpId = Convert.ToInt32(row["updtEmpId"]); } if (row["updtDt"] != DBNull.Value) { model.updtDt = Convert.ToString(row["updtDt"]); } return model; } else { return null; } }
/// <summary> /// ɾ�� /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { bool retChecked = false; GCalendarArrangeBB calendarArrangeBB = new GCalendarArrangeBB(); try { //��ȡѡ�е�����Id foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { retChecked = true; int id = int.Parse(chkId.ValidationGroup); GCalendarArrangeData calendarArrangeData = new GCalendarArrangeData(); calendarArrangeData = calendarArrangeBB.GetModel(id); calendarArrangeData.isDel = true; calendarArrangeBB.ModifyRecord(calendarArrangeData); } } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { calendarArrangeBB.Dispose(); } if (retChecked) { this.BindGrid(); } }