/// <summary> /// 得到一个对象实体 /// </summary> public zlzw.Model.GeneralADModel DataRowToModel(DataRow row) { zlzw.Model.GeneralADModel model=new zlzw.Model.GeneralADModel(); if (row != null) { if(row["ADID"]!=null && row["ADID"].ToString()!="") { model.ADID=int.Parse(row["ADID"].ToString()); } if(row["EnterpriseGuid"]!=null && row["EnterpriseGuid"].ToString()!="") { model.EnterpriseGuid= new Guid(row["EnterpriseGuid"].ToString()); } if(row["ADGuid"]!=null && row["ADGuid"].ToString()!="") { model.ADGuid= new Guid(row["ADGuid"].ToString()); } if(row["ADName"]!=null) { model.ADName=row["ADName"].ToString(); } if(row["ADImageKey"]!=null) { model.ADImageKey=row["ADImageKey"].ToString(); } if(row["ADImagePath"]!=null) { model.ADImagePath=row["ADImagePath"].ToString(); } if(row["ADScript"]!=null) { model.ADScript=row["ADScript"].ToString(); } if(row["ADTargetUrl"]!=null) { model.ADTargetUrl=row["ADTargetUrl"].ToString(); } if(row["ADType"]!=null && row["ADType"].ToString()!="") { model.ADType=int.Parse(row["ADType"].ToString()); } if(row["ADKind"]!=null && row["ADKind"].ToString()!="") { model.ADKind= new Guid(row["ADKind"].ToString()); } if(row["ADCategory"]!=null) { model.ADCategory=row["ADCategory"].ToString(); } if(row["ADStatus"]!=null && row["ADStatus"].ToString()!="") { model.ADStatus=int.Parse(row["ADStatus"].ToString()); } if(row["DisplayStartDate"]!=null && row["DisplayStartDate"].ToString()!="") { model.DisplayStartDate=DateTime.Parse(row["DisplayStartDate"].ToString()); } if(row["DisplayEndDate"]!=null && row["DisplayEndDate"].ToString()!="") { model.DisplayEndDate=DateTime.Parse(row["DisplayEndDate"].ToString()); } if(row["ADDesc"]!=null) { model.ADDesc=row["ADDesc"].ToString(); } if(row["ADMemo"]!=null) { model.ADMemo=row["ADMemo"].ToString(); } if(row["ADOrderNumber"]!=null && row["ADOrderNumber"].ToString()!="") { model.ADOrderNumber=int.Parse(row["ADOrderNumber"].ToString()); } if(row["ADWidth"]!=null && row["ADWidth"].ToString()!="") { model.ADWidth=int.Parse(row["ADWidth"].ToString()); } if(row["ADHeight"]!=null && row["ADHeight"].ToString()!="") { model.ADHeight=int.Parse(row["ADHeight"].ToString()); } if(row["CreateUserKey"]!=null) { model.CreateUserKey=row["CreateUserKey"].ToString(); } if(row["CreateUserName"]!=null) { model.CreateUserName=row["CreateUserName"].ToString(); } if(row["CreateDate"]!=null && row["CreateDate"].ToString()!="") { model.CreateDate=DateTime.Parse(row["CreateDate"].ToString()); } if(row["UpdateDate"]!=null && row["UpdateDate"].ToString()!="") { model.UpdateDate=DateTime.Parse(row["UpdateDate"].ToString()); } if(row["RefreshDate"]!=null && row["RefreshDate"].ToString()!="") { model.RefreshDate=DateTime.Parse(row["RefreshDate"].ToString()); } if(row["ADOwnerKey"]!=null) { model.ADOwnerKey=row["ADOwnerKey"].ToString(); } if(row["ADOwnerName"]!=null) { model.ADOwnerName=row["ADOwnerName"].ToString(); } if(row["CanUsable"]!=null && row["CanUsable"].ToString()!="") { model.CanUsable=int.Parse(row["CanUsable"].ToString()); } if(row["PropertyNames"]!=null) { model.PropertyNames=row["PropertyNames"].ToString(); } if(row["PropertyValues"]!=null) { model.PropertyValues=row["PropertyValues"].ToString(); } } return model; }
protected void btnSaveRefresh_Click(object sender, EventArgs e) { if (Request.QueryString["Type"] == "1") { //编辑保存 zlzw.Model.GeneralADModel generalADModel = new zlzw.Model.GeneralADModel(); generalADModel.ADName = txbADName.Text;//广告名称 //generalADModel.ADType = int.Parse(drpADType.SelectedValue);//广告类型 generalADModel.ADType = 1;//广告类型 //generalADModel.ADScript = txbADScript.Text;//广告脚本 //generalADModel.ADTargetUrl = txbADTargetUrl.Text;//跳转地址 generalADModel.CreateDate = DateTime.Parse(ViewState["CreateDate"].ToString()); generalADModel.UpdateDate = DateTime.Now;//更新日期 generalADModel.ADOrderNumber = int.Parse(txbOrderNumber.Text);//排序字段 generalADModel.ADStatus = 1; generalADModel.DisplayStartDate = DateTime.Parse(dateStartTime.Text);//开始日期 generalADModel.DisplayEndDate = DateTime.Parse(dateEndTime.Text);//结束日期 if (fileUploadImage.PostedFile.ContentLength > 0) { fileUploadImage.SaveAs(Server.MapPath(ViewState["ADImagePath"].ToString())); generalADModel.ADImagePath = ViewState["ADImagePath"].ToString(); } else { generalADModel.ADImagePath = ViewState["ADImagePath"].ToString(); } generalADModel.EnterpriseGuid = new Guid(drpEnterpriseType.SelectedValue);//所属企业GUID generalADModel.CreateUserKey = Request.Cookies["UserID"].Value;//创建人GUID generalADModel.CreateUserName = Get_UserName(); generalADModel.CanUsable = 1; generalADModel.ADDesc = txbADDesc.Text;//广告简介 generalADModel.ADGuid = new Guid(ViewState["ADGuid"].ToString()); zlzw.BLL.GeneralADBLL generalADBLL = new zlzw.BLL.GeneralADBLL(); generalADModel.ADID = int.Parse(Get_ID(generalADBLL, Request.QueryString["value"])); generalADBLL.Update(generalADModel); } else { //添加保存 zlzw.Model.GeneralADModel generalADModel = new zlzw.Model.GeneralADModel(); generalADModel.ADName = txbADName.Text;//广告名称 generalADModel.ADType = 1;//广告类型 //generalADModel.ADScript = txbADScript.Text;//广告脚本 //generalADModel.ADTargetUrl = txbADTargetUrl.Text;//跳转地址 generalADModel.ADOrderNumber = int.Parse(txbOrderNumber.Text);//排序字段 generalADModel.CreateDate = DateTime.Now;//创建日期 generalADModel.UpdateDate = DateTime.Now;//更新日期 generalADModel.ADStatus = 1; generalADModel.CanUsable = 1; generalADModel.DisplayStartDate = DateTime.Parse(dateStartTime.Text);//开始日期 generalADModel.DisplayEndDate = DateTime.Parse(dateEndTime.Text);//结束日期 if (fileUploadImage.PostedFile.ContentLength > 0) { string fileName = DateTime.Now.Ticks.ToString() + "_" + fileUploadImage.FileName; fileUploadImage.SaveAs(Server.MapPath("~/UploadImages/" + fileName)); generalADModel.ADImagePath = "~/UploadImages/" + fileName;//保存广告图片路径 } generalADModel.EnterpriseGuid = new Guid(drpEnterpriseType.SelectedValue);//所属企业GUID generalADModel.CreateUserKey = Request.Cookies["UserID"].Value;//创建人GUID generalADModel.CreateUserName = Get_UserName(); generalADModel.ADDesc = txbADDesc.Text;//广告简介 zlzw.BLL.GeneralADBLL generalADBLL = new zlzw.BLL.GeneralADBLL(); generalADBLL.Add(generalADModel); } // 2. Close this window and Refresh parent window PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); }
/// <summary> /// 得到一个对象实体 /// </summary> public zlzw.Model.GeneralADModel GetModel(int ADID) { SqlParameter[] parameters = { new SqlParameter("@ADID", SqlDbType.Int,4) }; parameters[0].Value = ADID; zlzw.Model.GeneralADModel model=new zlzw.Model.GeneralADModel(); DataSet ds= DbHelperSQL.RunProcedure("GeneralAD_GetModel",parameters,"ds"); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }