private void OnStart() { InputData(); switch (CMD) { case "New": CMD_Txt = "增加"; HiddenDisp(); TopTr.Visible = false; break; case "Edit": CMD_Txt = "修改"; HiddenDisp(); HeadMenuButtonItem Bm0 = new HeadMenuButtonItem(); Bm0.ButtonPopedom = PopedomType.List; Bm0.ButtonUrl = string.Format("?CMD=Look&S_ID={0}", S_ID); Bm0.ButtonIcon = "back.gif"; Bm0.ButtonName = "返回"; HeadMenuWebControls1.ButtonList.Add(Bm0); HeadMenuButtonItem Bm1 = new HeadMenuButtonItem(); Bm1.ButtonPopedom = PopedomType.Delete; Bm1.ButtonUrlType = UrlType.JavaScript; Bm1.ButtonUrl = string.Format("DelData('?CMD=Delete&S_ID={0}')", S_ID); HeadMenuWebControls1.ButtonList.Add(Bm1); break; case "Look": HiddenInput(); HeadMenuButtonItem Bm2 = new HeadMenuButtonItem(); Bm2.ButtonPopedom = PopedomType.Edit; Bm2.ButtonUrl = string.Format("?CMD=Edit&S_ID={0}", S_ID); HeadMenuWebControls1.ButtonList.Add(Bm2); break; case "Delete": CMD_Txt = "删除"; PM_ProjectsTable sat = new PM_ProjectsTable(); sat.ProjectId = S_ID.ToString(); sat.DB_Option_Action_ = CMD; BusinessFacade.PM_ProjectsTableInsertUpdate(sat); EventMessage.MessageBox(1, "操作成功", "删除记录ID:(" + S_ID + ")成功!", Icon_Type.OK, Common.GetHomeBaseUrl("ProjectList.aspx")); break; } All_Title_Txt = CMD_Txt + App_Txt; HeadMenuWebControls1.HeadOPTxt = TabOptionItem1.Tab_Name = All_Title_Txt; }
/// <summary> /// 新增/删除/修改 PM_ProjectsTable /// </summary> /// <param name="fam">PM_ProjectsTable实体类</param> /// <returns>返回0操正常</returns> public override int PM_ProjectsTableInsertUpdate(PM_ProjectsTable fam) { int rInt = 0; using (SqlConnection Conn = GetSqlConnection()) { SqlCommand cmd = new SqlCommand("PM_ProjectsInsertUpdateDelete", Conn); cmd.CommandType = CommandType.StoredProcedure; //设置参数 cmd.Parameters.Add("@DB_Option_Action_", SqlDbType.NVarChar).Value = fam.DB_Option_Action_; //操作方法 Insert:增加 Update:修改 Delete:删除 Disp:显示单笔记录 if (fam.DB_Option_Action_.Equals("Insert", StringComparison.OrdinalIgnoreCase)) { cmd.Parameters.Add("@ProjectId", SqlDbType.UniqueIdentifier).Value = Guid.NewGuid(); } else { cmd.Parameters.Add("@ProjectId", SqlDbType.UniqueIdentifier).Value = new Guid(fam.ProjectId); } cmd.Parameters.Add("@ProjectNo", SqlDbType.NVarChar).Value = fam.ProjectNo; cmd.Parameters.Add("@ProjectName", SqlDbType.NVarChar).Value = fam.ProjectName; cmd.Parameters.Add("@ProjectStatus", SqlDbType.Int).Value = fam.ProjectStatus; cmd.Parameters.Add("@ProjectStartTime", SqlDbType.DateTime).Value = fam.ProjectStartTime; cmd.Parameters.Add("@ProjectDuration", SqlDbType.Int).Value = fam.ProjectDuration; cmd.Parameters.Add("@ProjectBrief", SqlDbType.NVarChar).Value = fam.ProjectBrief; cmd.Parameters.Add("@ProjectComments", SqlDbType.NVarChar).Value = fam.ProjectComments; cmd.Parameters.Add("@ProjectIcon", SqlDbType.NVarChar).Value = fam.ProjectIcon; Conn.Open(); rInt = Convert.ToInt32(cmd.ExecuteScalar()); cmd.Dispose(); Conn.Dispose(); Conn.Close(); } return rInt; }
/// <summary> /// 新增/删除/修改 PM_ProjectsTable /// </summary> /// <param name="fam">PM_ProjectsTable实体类</param> /// <returns>返回0操正常</returns> public abstract int PM_ProjectsTableInsertUpdate(PM_ProjectsTable fam);
/// <summary> /// 将记录集转为PM_ProjectsTable实体类 /// </summary> /// <param name="dr">记录集</param> /// <returns>PM_ProjectsTable</returns> protected object PopulatePM_ProjectsTable(IDataReader dr) { PM_ProjectsTable nc = new PM_ProjectsTable(); if (!Convert.IsDBNull(dr["ProjectId"])) nc.ProjectId = Convert.ToString(dr["ProjectId"]).Trim(); if (!Convert.IsDBNull(dr["ProjectNo"])) nc.ProjectNo = Convert.ToString(dr["ProjectNo"]).Trim(); if (!Convert.IsDBNull(dr["ProjectName"])) nc.ProjectName = Convert.ToString(dr["ProjectName"]).Trim(); if (!Convert.IsDBNull(dr["ProjectStatus"])) nc.ProjectStatus = Convert.ToInt32(dr["ProjectStatus"]); if (!Convert.IsDBNull(dr["ProjectStartTime"])) nc.ProjectStartTime = Convert.ToDateTime(dr["ProjectStartTime"]); if (!Convert.IsDBNull(dr["ProjectDuration"])) nc.ProjectDuration = Convert.ToDouble(dr["ProjectDuration"]); if (!Convert.IsDBNull(dr["ProjectBrief"])) nc.ProjectBrief = Convert.ToString(dr["ProjectBrief"]).Trim(); if (!Convert.IsDBNull(dr["ProjectComments"])) nc.ProjectComments = Convert.ToString(dr["ProjectComments"]).Trim(); if (!Convert.IsDBNull(dr["ProjectIcon"])) nc.ProjectIcon = Convert.ToString(dr["ProjectIcon"]).Trim(); return nc; }
protected void ButtonOK_Click(object sender, EventArgs e) { PM_ProjectsTable sat = new PM_ProjectsTable(); sat.ProjectId = S_ID.ToString(); sat.ProjectNo = string.Format("No{0}", DateTime.Now.ToString("yyyyMMddHHmmss")); sat.ProjectName = (string)Common.sink(textBoxProjectName.UniqueID, MethodType.Post, 50, 1, DataType.Str); sat.ProjectStatus =Convert.ToInt32(DropDownListProjectStatus.SelectedValue); sat.ProjectStartTime = (DateTime)Common.sink(textBoxProjectStartTime.UniqueID, MethodType.Post, 100, 1, DataType.Dat); sat.ProjectDuration =(int)Common.sink(textBoxProjectDuration.UniqueID, MethodType.Post, 50, 1, DataType.Int); sat.ProjectBrief = (string)Common.sink(textProjectBrief.UniqueID, MethodType.Post, 500, 0, DataType.Str); sat.ProjectComments = (string)Common.sink(textProjectComments.UniqueID, MethodType.Post, 500, 0, DataType.Str); sat.ProjectIcon = (string)Common.sink(textProjectIcon.UniqueID, MethodType.Post, 100, 0, DataType.Str); switch (CMD) { case "New": CMD_Txt = "增加"; sat.DB_Option_Action_ = "Insert"; break; case "Edit": CMD_Txt = "修改"; sat.DB_Option_Action_ = "Update"; break; } All_Title_Txt = CMD_Txt + App_Txt; BusinessFacade.PM_ProjectsTableInsertUpdate(sat); EventMessage.MessageBox(1, "操作成功", string.Format("{1}ID({0})成功!", S_ID, All_Title_Txt), Icon_Type.OK, Common.GetHomeBaseUrl("ProjectList.aspx")); }
/// <summary> /// 新增/删除/修改 PM_ProjectsTable /// </summary> /// <param name="fam">PM_ProjectsTable实体类</param> /// <returns>返回0操正常</returns> public static int PM_ProjectsTableInsertUpdate(PM_ProjectsTable fam) { return DataProvider.Instance().PM_ProjectsTableInsertUpdate(fam); }
/// <summary> /// 根据ID返回 PM_ProjectsTable实体类 单笔资料 /// </summary> /// <param name="ProjectId">自动ID </param> /// <returns>返回PM_ProjectsTable实体类 </returns> public static PM_ProjectsTable PM_ProjectsDisp(string ProjectId) { PM_ProjectsTable fam = new PM_ProjectsTable(); QueryParam qp = new QueryParam(); qp.PageIndex = 1; qp.PageSize = 1; qp.Where = " Where PM_Project.ProjectId = '" + ProjectId +"'"; int RecordCount = 0; ArrayList lst = PM_ProjectsList(qp, out RecordCount); if (RecordCount > 0) { fam = (PM_ProjectsTable)lst[0]; } return fam; }