/// <summary> /// 设置初始界面 /// </summary> private void fill() { try { Song.Entities.ProductFactory mm; if (id != 0) { mm = Business.Do <IProduct>().FactorySingle(id); //是否使用与显示 cbIsUse.Checked = mm.Pfact_IsUse; } else { //如果是新增 mm = new Song.Entities.ProductFactory(); cbIsUse.Checked = true; } tbName.Text = mm.Pfact_Name; tbAddr.Text = mm.Pfact_Addr; tbTel.Text = mm.Pfact_Tel; tbZip.Text = mm.Pfact_Zip; tbWebsite.Text = mm.Pfact_Website; //说明 this.tbIntro.Text = mm.Pfact_Intro; } catch (Exception ex) { Message.ExceptionShow(ex); } }
/// <summary> /// 修改是否使用的状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void sbUse_Click(object sender, EventArgs e) { try { StateButton ub = (StateButton)sender; int index = ((GridViewRow)(ub.Parent.Parent)).RowIndex; int id = int.Parse(this.GridView1.DataKeys[index].Value.ToString()); // Song.Entities.ProductFactory entity = Business.Do <IProduct>().FactorySingle(id); entity.Pfact_IsUse = !entity.Pfact_IsUse; Business.Do <IProduct>().FactorySave(entity); BindData(null, null); } catch (Exception ex) { Message.ExceptionShow(ex); } }
/// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEnter_Click(object sender, EventArgs e) { try { Song.Entities.ProductFactory mm; if (id != 0) { mm = Business.Do <IProduct>().FactorySingle(id); } else { //如果是新增 mm = new Song.Entities.ProductFactory(); } mm.Pfact_Name = tbName.Text; mm.Pfact_Addr = tbAddr.Text; mm.Pfact_Tel = tbTel.Text; mm.Pfact_Zip = tbZip.Text; mm.Pfact_Website = tbWebsite.Text; //是否使用与显示 mm.Pfact_IsUse = cbIsUse.Checked; mm.Pfact_Intro = tbIntro.Text; //确定操作 if (id == 0) { Business.Do <IProduct>().FactoryAdd(mm); } else { Business.Do <IProduct>().FactorySave(mm); } Master.AlertCloseAndRefresh("操作成功!"); } catch (Exception ex) { Message.ExceptionShow(ex); } }