public Model.Speciality Convert(SpecialityParam param, Model.Speciality oldEntity) { Model.Speciality entity = null; if (oldEntity != null) { entity = oldEntity; } else { entity = new Model.Speciality() { Code = param.Code, Id = param.Id, Description = param.Description, Name = param.Name }; } entity.Status = StatusDao.Find(param.StatusId); entity.EducationalDegrees = param.EducationalDegrees; entity.TrainingType = param.TrainingType; return(entity); }
public Model.Speciality Update(Model.Speciality entity) { Delete(entity.Id); Save(entity); return(entity); }
internal void FormToEdit(Speciality model) { //填值 cbCollege.SelectedValue = model.College_id; txtSpecialityName.Text = model.Name; txtRemark.Text = model.Remark; //卸载事件 btnOk.Click -= this.btnOk_Click; //注册事件 btnOk.Click += new EventHandler((a, b) => { BLL.SpecialityBLL bll = new BLL.SpecialityBLL(); //取值 Model.Speciality model_speciality = GetModelByUI(); model_speciality.Id = model.Id; //传递model的Id if (bll.UpdateSpecialityBySpecialityId(model_speciality)) { CCWin.MessageBoxEx.Show("修改成功!!!"); this.DialogResult = DialogResult.OK; this.Close(); } else { CCWin.MessageBoxEx.Show("修改失败,该数据可能已被删除或服务器连接中断,请刷新后重试!"); } }); }
public SpecialityResult Find(long id) { Model.Speciality entity = Dao.Find(id); SpecialityResult result = ResultConverter.Convert(entity); return(result); }
private void initPage() { editType = Convert.ToInt32(Request.QueryString["editType"]); modelspeciality = bllspeciality.GetModel(Convert.ToInt32(spcId)); if (modelspeciality != null) { spcDir = modelspeciality.dbo_HtmlDir.ToString() + "/"; } fileName = string.Empty; switch (editType) { case 1: fileName = "default.aspx"; litEditType.Text = "首页"; break; case 2: fileName = "showList.aspx"; litEditType.Text = "列表页"; break; case 3: fileName = "ShowArticle.aspx"; litEditType.Text = "内容页"; break; case 4: fileName = "search.aspx"; litEditType.Text = "搜索页"; break; default: fileName = "default.aspx"; litEditType.Text = "首页"; break; } fileFullPath = Server.MapPath("~/") + spcDir + fileName; if (editType == 4) { fileFullPath = Server.MapPath("~/") + "search.aspx"; } }
public Model.Speciality Save(Model.Speciality entity) { SpecialityDaoStorage.Specialities.Add(entity); SpecialityDaoStorage.Dictionary.Add(entity.Id, entity); return(entity); }
//public SpecialityProcessor(ISpecialityDao dao, ISpecialityParamConverter paramConverter, // ISpecialityResultConverter resultConverter) //{ // this.Dao = dao; // this.ParamConverter = paramConverter; // this.ResultConverter = resultConverter; //} public SpecialityResult Create(SpecialityParam param) { Model.Speciality entity = ParamConverter.Convert(param, null); entity = Dao.Save(entity); return(ResultConverter.Convert(entity)); }
/// <summary> /// 从界面取得值,用来填充Model.Speciality /// </summary> /// <returns></returns> private Speciality GetModelByUI() { Model.Speciality model_speciality = new Model.Speciality(); model_speciality.Name = txtSpecialityName.Text.Trim(); model_speciality.College_id = (int)cbCollege.SelectedValue; model_speciality.Remark = txtRemark.Text; model_speciality.Submitter_id = frmMain.current_user.Id; return(model_speciality); }
public void Update(List <SpecialityParam> param) { //List<UniversityDemo.Speciality> entities = new List<UniversityDemo.Speciality>(); foreach (var item in param) { Model.Speciality oldEntity = Dao.Find(item.Id); Model.Speciality newEntity = ParamConverter.Convert(item, null); Dao.Update(newEntity); } }
private void initEdit() { modelspeciality = bllspeciality.GetModel(Convert.ToInt32(Request.QueryString["id"])); if (modelspeciality != null) { this.txtName.Text = modelspeciality.dbo_Name; this.txtDir.Text = modelspeciality.dbo_HtmlDir; this.fckContent.Text = modelspeciality.dbo_ContentHtml; this.chkIfshow.Checked = modelspeciality.dbo_IfShow; this.txtLinkurl.Text = modelspeciality.dbo_LinkUrl; this.txtDir.Enabled = false; } }
public void Update(long id, SpecialityParam param) { Model.Speciality oldEntity = Dao.Find(id); if (oldEntity != null) { Dao.Delete(oldEntity); Dao.Update(ParamConverter.Convert(param, null)); } else { Console.WriteLine($"No entity with Id = {id} was found"); } }
private void btnEditSpeciality_Click(object sender, EventArgs e) { if (dgvSepciality.SelectedRows.Count > 0) //是否选中 { Model.Speciality model = (Model.Speciality)dgvSepciality.SelectedRows[0].DataBoundItem; //选中行转换为Model frmAddSpeciality frm = new frmAddSpeciality(); frm.Text = "正在修改 " + model.Name + " 专业"; frm.FormToEdit(model); //更改窗体用途 if (frm.ShowDialog() == DialogResult.OK) { LoadAllSpecialityByDelFlagAndCollegeId(); //刷新 } } }
protected void btnAdd_Click(object sender, EventArgs e) { string strName = this.txtName.Text; string strDir = this.txtDir.Text; string strfckContent = this.fckContent.Text; bool ifshow = this.chkIfshow.Checked; string strlinkurl = this.txtLinkurl.Text; string destPath = Server.MapPath("~/") + strDir; string sourcePath = Server.MapPath("~/") + "templates/specially/"; DirectoryInfo di = new DirectoryInfo(destPath); DirectoryInfo dirSource = new DirectoryInfo(sourcePath); if (theState == MyPageState.add) { if (di.Exists) { Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert(\"目录已存在,请重新输入目录名称!\")", true); return; } //数据库中添加记录 bllspeciality.Add(new Model.Speciality { dbo_Name = strName, dbo_HtmlDir = strDir, dbo_ContentHtml = strfckContent, dbo_IfShow = ifshow, dbo_LinkUrl = strlinkurl }); //新增文件夹目录 di.Create(); FileInfo[] files = dirSource.GetFiles("*.aspx"); foreach (FileInfo f in files) { f.CopyTo(destPath + "/" + f.Name); } } else if (theState == MyPageState.edit) { int id = Convert.ToInt32(Request.QueryString["id"]); modelspeciality = bllspeciality.GetModel(id); modelspeciality.dbo_Name = strName; modelspeciality.dbo_HtmlDir = strDir; modelspeciality.dbo_ContentHtml = strfckContent; modelspeciality.dbo_IfShow = ifshow; modelspeciality.dbo_LinkUrl = strlinkurl; bllspeciality.Update(modelspeciality); } Response.Write("<script>window.parent.frames['toolbar'].location.reload();window.location.href='specialityList.aspx';</script>"); }
private void btnOk_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtSpecialityName.Text)) { BLL.SpecialityBLL bll = new BLL.SpecialityBLL(); //取值 Model.Speciality model = GetModelByUI(); //添加 bool result = bll.AddSpeciality(model); CCWin.MessageBoxEx.Show(result ? "添加成功!!" : "添加失败,可能该数据已存在或数据库访问异常,请重试!!"); this.DialogResult = result ? DialogResult.OK : DialogResult.No; //设置窗体结果 if (result) { this.Close(); //如果添加成功则关闭窗体 } } }
public SpecialityResult Convert(Model.Speciality param) { SpecialityResult result = new SpecialityResult() { Id = param.Id, Code = param.Code, Name = param.Name, Description = param.Description, EducationalDegrees = param.EducationalDegrees, TrainingType = param.TrainingType, StatusId = param.Status.Id, StatusName = param.Status.Name }; return(result); }
static SpecialityDaoStorage() { Model.Speciality speciality1 = new Model.Speciality() { }; Model.Speciality speciality2 = new Model.Speciality() { }; Model.Speciality speciality3 = new Model.Speciality() { }; Specialities.Add(speciality1); Specialities.Add(speciality2); Specialities.Add(speciality3); Dictionary.Add(speciality1.Id, speciality1); Dictionary.Add(speciality2.Id, speciality2); Dictionary.Add(speciality3.Id, speciality3); }
public void Delete(Model.Speciality entity) { SpecialityDaoStorage.Specialities.Remove(entity); SpecialityDaoStorage.Dictionary.Remove(entity.Id); }
public void Delete(long id) { Model.Speciality entity = Find(id); Delete(entity); }