private void ShowInfo_branch(int id) { Maticsoft.BLL.branch_company bll = new Maticsoft.BLL.branch_company(); Maticsoft.Model.branch_company model = bll.GetModel_bypeixunban(id); this.txtstart_detail.Text = model.start_detail; this.txtend_detail.Text = model.end_detail; this.txtnum.Text = model.num.ToString(); this.txtnum_detail.Text = model.num_detail; this.txtcleaning_fee.Text = model.cleaning_fee.ToString(); this.txtfapiao_taitou.Text = model.fapiao_taitou; this.txtbasketball_time.Text = model.basketball_time.ToString(); this.txtfantang.Text = model.fantang; //this.txtfangka_print.Text = model.fangka_print.ToString(); //xishu_yongpin.Text = model.xishu_yongpin.ToString(); if (model.xishu_yongpin == 1) { xishu.SelectedIndex = 0; } else { xishu.SelectedIndex = 1; }; if (model.fangka_print == 1) { fangka_print.SelectedIndex = 0; } else { fangka_print.SelectedIndex = 1; }; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.branch_company model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into branch_company("); strSql.Append("peixunban_id,start_detail,end_detail,num,num_detail,cleaning_fee,fapiao_taitou,basketball_time,fantang,fangka_print,yuedu_shuoming,fengongsi,date,xishu_yongpin)"); strSql.Append(" values ("); strSql.Append("@peixunban_id,@start_detail,@end_detail,@num,@num_detail,@cleaning_fee,@fapiao_taitou,@basketball_time,@fantang,@fangka_print,@yuedu_shuoming,@fengongsi,@date,@xishu_yongpin)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@peixunban_id", SqlDbType.Int, 4), new SqlParameter("@start_detail", SqlDbType.Text), new SqlParameter("@end_detail", SqlDbType.Text), new SqlParameter("@num", SqlDbType.Int, 4), new SqlParameter("@num_detail", SqlDbType.Text), new SqlParameter("@cleaning_fee", SqlDbType.SmallMoney, 4), new SqlParameter("@fapiao_taitou", SqlDbType.NVarChar, 50), new SqlParameter("@basketball_time", SqlDbType.NVarChar, 50), new SqlParameter("@fantang", SqlDbType.Text), new SqlParameter("@fangka_print", SqlDbType.Int, 4), new SqlParameter("@yuedu_shuoming", SqlDbType.Int, 4), new SqlParameter("@fengongsi", SqlDbType.NVarChar, 50), new SqlParameter("@date", SqlDbType.DateTime), new SqlParameter("@xishu_yongpin", SqlDbType.Int, 4) }; parameters[0].Value = model.peixunban_id; parameters[1].Value = model.start_detail; parameters[2].Value = model.end_detail; parameters[3].Value = model.num; parameters[4].Value = model.num_detail; parameters[5].Value = model.cleaning_fee; parameters[6].Value = model.fapiao_taitou; parameters[7].Value = model.basketball_time; parameters[8].Value = model.fantang; parameters[9].Value = model.fangka_print; parameters[10].Value = model.yuedu_shuoming; parameters[11].Value = model.fengongsi; parameters[12].Value = model.date; parameters[13].Value = model.xishu_yongpin; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void ShowInfo(int id) { Maticsoft.BLL.branch_company bll = new Maticsoft.BLL.branch_company(); Maticsoft.Model.branch_company model = bll.GetModel(id); this.lblid.Text = model.id.ToString(); this.txtpeixunban_id.Text = model.peixunban_id.ToString(); this.txtstart_detail.Text = model.start_detail; this.txtend_detail.Text = model.end_detail; this.txtnum.Text = model.num.ToString(); this.txtnum_detail.Text = model.num_detail; this.txtcleaning_fee.Text = model.cleaning_fee.ToString(); this.txtfapiao_taitou.Text = model.fapiao_taitou; this.txtbasketball_time.Text = model.basketball_time.ToString(); this.txtfantang.Text = model.fantang; this.txtfangka_print.Text = model.fangka_print.ToString(); this.txtyuedu_shuoming.Text = model.yuedu_shuoming.ToString(); this.txtfengongsi.Text = model.fengongsi; this.txtdate.Text = model.date.ToString(); }
/// <summary> /// 通过培训班id获得分公司表的id /// </summary> /// <param name="peixunbanid"></param> /// <returns></returns> public int get_id(int peixunbanid) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id from branch_company "); strSql.Append(" where peixunban_id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = peixunbanid; Maticsoft.Model.branch_company model = new Maticsoft.Model.branch_company(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(Convert.ToInt16(ds.Tables[0].Rows[0]["id"])); } else { return(0); } }
/* * /// <summary> * /// 分页获取数据列表 * /// </summary> * public DataSet GetList(int PageSize,int PageIndex,string strWhere) * { * SqlParameter[] parameters = { * new SqlParameter("@tblName", SqlDbType.VarChar, 255), * new SqlParameter("@fldName", SqlDbType.VarChar, 255), * new SqlParameter("@PageSize", SqlDbType.Int), * new SqlParameter("@PageIndex", SqlDbType.Int), * new SqlParameter("@IsReCount", SqlDbType.Bit), * new SqlParameter("@OrderType", SqlDbType.Bit), * new SqlParameter("@strWhere", SqlDbType.VarChar,1000), * }; * parameters[0].Value = "branch_company"; * parameters[1].Value = "id"; * parameters[2].Value = PageSize; * parameters[3].Value = PageIndex; * parameters[4].Value = 0; * parameters[5].Value = 0; * parameters[6].Value = strWhere; * return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds"); * }*/ #endregion BasicMethod #region ExtensionMethod /// <summary> /// 通过培训班id得到一个对象实体 /// </summary> public Maticsoft.Model.branch_company GetModel_bypeixunban(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,peixunban_id,start_detail,end_detail,num,num_detail,cleaning_fee,fapiao_taitou,basketball_time,fantang,fangka_print,yuedu_shuoming,fengongsi,date,xishu_yongpin from branch_company "); strSql.Append(" where peixunban_id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Maticsoft.Model.branch_company model = new Maticsoft.Model.branch_company(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
private void ShowInfo(int id) { Maticsoft.BLL.peixunban1 bll = new Maticsoft.BLL.peixunban1(); Maticsoft.Model.peixunban1 model = bll.GetModel(id); this.lblstart_time.Text = Convert.ToDateTime(model.start_time.ToString()).ToShortDateString(); this.lblend_time.Text = Convert.ToDateTime(model.end_time.ToString()).ToShortDateString(); this.lblname.Text = model.name; contact.Text = model.contact; phone.Text = model.phone; beizhu.Text = model.beizhu; Maticsoft.BLL.branch_company bhc_bll = new BLL.branch_company(); Maticsoft.Model.branch_company bhc_mod = bhc_bll.GetModel_bypeixunban(id); start_detail.Text = bhc_mod.start_detail.ToString(); end_detail.Text = bhc_mod.end_detail.ToString(); num.Text = bhc_mod.num.ToString() + "人"; num_detail.Text = bhc_mod.num_detail.ToString(); cleaning_fee.Text = bhc_mod.cleaning_fee.ToString() + "元"; fapiao_taitou.Text = bhc_mod.fapiao_taitou.ToString(); basketball_time.Text = bhc_mod.basketball_time.ToString(); fantang.Text = bhc_mod.fantang.ToString(); fangka_print.Text = (bhc_mod.fangka_print == 1 ? "不打印名字" : "打印名字"); xishu_yongpin.Text = (bhc_mod.xishu_yongpin == 1 ? "简易洗漱用品" : "旅行套装"); }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtpeixunban_id.Text)) { strErr += "peixunban_id格式错误!\\n"; } if (this.txtstart_detail.Text.Trim().Length == 0) { strErr += "start_detail不能为空!\\n"; } if (this.txtend_detail.Text.Trim().Length == 0) { strErr += "end_detail不能为空!\\n"; } if (!PageValidate.IsNumber(txtnum.Text)) { strErr += "num格式错误!\\n"; } if (this.txtnum_detail.Text.Trim().Length == 0) { strErr += "num_detail不能为空!\\n"; } if (!PageValidate.IsDecimal(txtcleaning_fee.Text)) { strErr += "cleaning_fee格式错误!\\n"; } if (this.txtfapiao_taitou.Text.Trim().Length == 0) { strErr += "fapiao_taitou不能为空!\\n"; } if (!PageValidate.IsDateTime(txtbasketball_time.Text)) { strErr += "basketball_time格式错误!\\n"; } if (this.txtfantang.Text.Trim().Length == 0) { strErr += "fantang不能为空!\\n"; } if (!PageValidate.IsNumber(txtfangka_print.Text)) { strErr += "fangka_print格式错误!\\n"; } if (!PageValidate.IsNumber(txtyuedu_shuoming.Text)) { strErr += "yuedu_shuoming格式错误!\\n"; } if (this.txtfengongsi.Text.Trim().Length == 0) { strErr += "fengongsi不能为空!\\n"; } if (!PageValidate.IsDateTime(txtdate.Text)) { strErr += "date格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int id = int.Parse(this.lblid.Text); int peixunban_id = int.Parse(this.txtpeixunban_id.Text); string start_detail = this.txtstart_detail.Text; string end_detail = this.txtend_detail.Text; int num = int.Parse(this.txtnum.Text); string num_detail = this.txtnum_detail.Text; decimal cleaning_fee = decimal.Parse(this.txtcleaning_fee.Text); string fapiao_taitou = this.txtfapiao_taitou.Text; string basketball_time = this.txtbasketball_time.Text; string fantang = this.txtfantang.Text; int fangka_print = int.Parse(this.txtfangka_print.Text); int yuedu_shuoming = int.Parse(this.txtyuedu_shuoming.Text); string fengongsi = this.txtfengongsi.Text; DateTime date = DateTime.Parse(this.txtdate.Text); Maticsoft.Model.branch_company model = new Maticsoft.Model.branch_company(); model.id = id; model.peixunban_id = peixunban_id; model.start_detail = start_detail; model.end_detail = end_detail; model.num = num; model.num_detail = num_detail; model.cleaning_fee = cleaning_fee; model.fapiao_taitou = fapiao_taitou; model.basketball_time = basketball_time; model.fantang = fantang; model.fangka_print = fangka_print; model.yuedu_shuoming = yuedu_shuoming; model.fengongsi = fengongsi; model.date = date; Maticsoft.BLL.branch_company bll = new Maticsoft.BLL.branch_company(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsDateTime(txtstart_time.Text)) { strErr += "开始时间格式错误!\\n"; } if (!PageValidate.IsDateTime(txtend_time.Text)) { strErr += "结束时间格式错误!\\n"; } if (this.txtname.Text.Trim().Length == 0) { strErr += "培训班名称不能为空!\\n"; } if (this.txtcontact.Text.Trim().Length == 0) { strErr += "联系人不能为空!\\n"; } if (this.txtphone.Text.Trim().Length == 0) { strErr += "联系电话不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int id = int.Parse(id_load); DateTime start_time = DateTime.Parse(this.txtstart_time.Text); DateTime end_time = DateTime.Parse(this.txtend_time.Text); string name = this.txtname.Text; string contact = this.txtcontact.Text; int sinal = 2; string beizhu = this.txtbeizhu.Text; string phone = this.txtphone.Text; Maticsoft.Model.peixunban1 model = new Maticsoft.Model.peixunban1(); model.id = id; model.start_time = start_time; model.end_time = end_time; model.name = name; model.contact = contact; model.sinal = sinal; model.beizhu = beizhu; model.phone = phone; Maticsoft.BLL.peixunban1 bll = new Maticsoft.BLL.peixunban1(); bll.Update(model); #region 开始branch_company表的数据更新 Maticsoft.BLL.branch_company bnc_bll = new BLL.branch_company(); Maticsoft.Model.branch_company bnc_mod = bnc_bll.GetModel_bypeixunban(id); if (this.txtstart_detail.Text.Trim().Length == 0) { strErr += "入住具体时间不能为空!\\n"; } if (this.txtend_detail.Text.Trim().Length == 0) { strErr += "退房具体时间不能为空!\\n"; } if (!PageValidate.IsNumber(txtnum.Text)) { strErr += "人数格式错误!\\n"; } if (!PageValidate.IsDecimal(txtcleaning_fee.Text)) { strErr += "清洁费用格式错误!\\n"; } if (this.txtfapiao_taitou.Text.Trim().Length == 0) { strErr += "发票抬头不能为空!\\n"; } if (this.txtfantang.Text.Trim().Length == 0) { strErr += "饭堂订餐不能为空!\\n"; } //if (!PageValidate.IsNumber(txtfangka_print.Text)) //{ // strErr += "fangka_print格式错误!\\n"; //} if (strErr != "") { MessageBox.Show(this, strErr); return; } string start_detail = this.txtstart_detail.Text; string end_detail = this.txtend_detail.Text; int num = int.Parse(this.txtnum.Text); string num_detail = this.txtnum_detail.Text; decimal cleaning_fee = decimal.Parse(this.txtcleaning_fee.Text); string fapiao_taitou = this.txtfapiao_taitou.Text; string basketball_time = this.txtbasketball_time.Text; string fantang = this.txtfantang.Text; //int fangka_print1 = int.Parse(this.txtfangka_print.Text); Maticsoft.Model.branch_company model_branch = new Maticsoft.Model.branch_company(); model_branch.id = bnc_mod.id; model_branch.peixunban_id = id; model_branch.start_detail = start_detail; model_branch.end_detail = end_detail; model_branch.num = num; model_branch.num_detail = num_detail; model_branch.cleaning_fee = cleaning_fee; model_branch.fapiao_taitou = fapiao_taitou; model_branch.basketball_time = basketball_time; model_branch.fantang = fantang; model_branch.fangka_print = Convert.ToInt16(fangka_print.SelectedValue); model_branch.fengongsi = bnc_mod.fengongsi; model_branch.date = DateTime.Today; model_branch.xishu_yongpin = Convert.ToInt16(xishu.SelectedValue); Maticsoft.BLL.branch_company bll_branch = new Maticsoft.BLL.branch_company(); bll_branch.Update(model_branch); #endregion Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.branch_company model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update branch_company set "); strSql.Append("peixunban_id=@peixunban_id,"); strSql.Append("start_detail=@start_detail,"); strSql.Append("end_detail=@end_detail,"); strSql.Append("num=@num,"); strSql.Append("num_detail=@num_detail,"); strSql.Append("cleaning_fee=@cleaning_fee,"); strSql.Append("fapiao_taitou=@fapiao_taitou,"); strSql.Append("basketball_time=@basketball_time,"); strSql.Append("fantang=@fantang,"); strSql.Append("fangka_print=@fangka_print,"); strSql.Append("yuedu_shuoming=@yuedu_shuoming,"); strSql.Append("fengongsi=@fengongsi,"); strSql.Append("date=@date,"); strSql.Append("xishu_yongpin=@xishu_yongpin"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@peixunban_id", SqlDbType.Int, 4), new SqlParameter("@start_detail", SqlDbType.Text), new SqlParameter("@end_detail", SqlDbType.Text), new SqlParameter("@num", SqlDbType.Int, 4), new SqlParameter("@num_detail", SqlDbType.Text), new SqlParameter("@cleaning_fee", SqlDbType.SmallMoney, 4), new SqlParameter("@fapiao_taitou", SqlDbType.NVarChar, 50), new SqlParameter("@basketball_time", SqlDbType.NVarChar, 50), new SqlParameter("@fantang", SqlDbType.Text), new SqlParameter("@fangka_print", SqlDbType.Int, 4), new SqlParameter("@yuedu_shuoming", SqlDbType.Int, 4), new SqlParameter("@fengongsi", SqlDbType.NVarChar, 50), new SqlParameter("@date", SqlDbType.DateTime), new SqlParameter("@xishu_yongpin", SqlDbType.Int, 4), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.peixunban_id; parameters[1].Value = model.start_detail; parameters[2].Value = model.end_detail; parameters[3].Value = model.num; parameters[4].Value = model.num_detail; parameters[5].Value = model.cleaning_fee; parameters[6].Value = model.fapiao_taitou; parameters[7].Value = model.basketball_time; parameters[8].Value = model.fantang; parameters[9].Value = model.fangka_print; parameters[10].Value = model.yuedu_shuoming; parameters[11].Value = model.fengongsi; parameters[12].Value = model.date; parameters[13].Value = model.xishu_yongpin; parameters[14].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.branch_company DataRowToModel(DataRow row) { Maticsoft.Model.branch_company model = new Maticsoft.Model.branch_company(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["peixunban_id"] != null && row["peixunban_id"].ToString() != "") { model.peixunban_id = int.Parse(row["peixunban_id"].ToString()); } if (row["start_detail"] != null) { model.start_detail = row["start_detail"].ToString(); } if (row["end_detail"] != null) { model.end_detail = row["end_detail"].ToString(); } if (row["num"] != null && row["num"].ToString() != "") { model.num = int.Parse(row["num"].ToString()); } if (row["num_detail"] != null) { model.num_detail = row["num_detail"].ToString(); } if (row["cleaning_fee"] != null && row["cleaning_fee"].ToString() != "") { model.cleaning_fee = decimal.Parse(row["cleaning_fee"].ToString()); } if (row["fapiao_taitou"] != null) { model.fapiao_taitou = row["fapiao_taitou"].ToString(); } if (row["basketball_time"] != null) { model.basketball_time = row["basketball_time"].ToString(); } if (row["fantang"] != null) { model.fantang = row["fantang"].ToString(); } if (row["fangka_print"] != null && row["fangka_print"].ToString() != "") { model.fangka_print = int.Parse(row["fangka_print"].ToString()); } if (row["yuedu_shuoming"] != null && row["yuedu_shuoming"].ToString() != "") { model.yuedu_shuoming = int.Parse(row["yuedu_shuoming"].ToString()); } if (row["fengongsi"] != null) { model.fengongsi = row["fengongsi"].ToString(); } if (row["date"] != null && row["date"].ToString() != "") { model.date = DateTime.Parse(row["date"].ToString()); } if (row["xishu_yongpin"] != null && row["xishu_yongpin"].ToString() != "") { model.xishu_yongpin = int.Parse(row["xishu_yongpin"].ToString()); } } return(model); }