public void delete() { //删除信息 //要删除的纪录的ID,保存在delList隐藏控件内 string id = delList.Text; if (!string.IsNullOrEmpty(id)) { data_conn cn = new data_conn(); string sql = null; sql = ""; sql = sql + "delete from tb_yunjia where ID in (" + id + ")"; cn.mdb_exe(sql); sql = "UPDATE TB_PRICECOUNT SET TB_PRICECOUNT.lclcount = (SELECT COUNT(tb_yunjia.id) AS yunjiacount FROM tb_yunjia,tb_yunjiainfo WHERE (yunjialeixing = 9) AND tb_yunjia.id = tb_yunjiainfo.yunjiaid),TB_PRICECOUNT.countdate = getdate() where TB_PRICECOUNT.cid = 1"; cn.mdb_exe(sql); MessageBox("opsuccess", "删除成功"); //清空delList delList.Text = ""; //同步topnew topnew tp = new topnew(); tp.CheckTopNew("9", this.Request.Cookies["user_id"].Value.ToString()); } else { //没有选择任何要删除的ID,弹出此对话框 MessageBox("opfail", "未选择任何要删除的项目"); } }
public void update() { //更新信息 //要更新的纪录的ID,保存在delList隐藏控件内 string id = delList.Text; if (!string.IsNullOrEmpty(id)) { data_conn cn = new data_conn(); string enddate = ""; DateTime dt = DateTime.Now; DateTime startMonth = dt.AddDays(1 - dt.Day); DateTime endMonth = startMonth.AddMonths(1).AddDays(-1); if (DateTime.Now.Day >= 15) { enddate = endMonth.ToString().Split(' ')[0]; } else { enddate = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + "15"; } string sql = null; sql = ""; sql = sql + "update tb_yunjia set PostDate=getdate(),enddate='" + enddate + "' where ID in (" + id + ")"; cn.mdb_exe(sql); sql = ""; sql = sql + "update TB_YunJiaInfo set PostDatex=getdate(),enddatex='" + enddate + "' where ID in (" + id + ")"; cn.mdb_exe(sql); sql = "UPDATE TB_PRICECOUNT SET TB_PRICECOUNT.fclcount = (SELECT COUNT(tb_yunjia.id) AS yunjiacount FROM tb_yunjia,tb_yunjiainfo WHERE (yunjialeixing = 9) AND tb_yunjia.id = tb_yunjiainfo.yunjiaid),TB_PRICECOUNT.countdate = getdate() where TB_PRICECOUNT.cid = 1"; cn.mdb_exe(sql); MessageBox("opsuccess", "更新成功"); //清空delList delList.Text = ""; //同步topnew topnew tp = new topnew(); tp.CheckTopNew("9", this.Request.Cookies["user_id"].Value.ToString()); } else { //没有选择任何要删除的ID,弹出此对话框 MessageBox("opfail", "未选择任何要更新的项目"); } }