/// <summary> /// 更新一条数据 /// </summary> public int Update(RSH_BaziConditionMod model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update RSH_BaziCondition set "); SqlCommand cmd = new SqlCommand(); if (model.SysNo != AppConst.IntNull) { SqlParameter param = new SqlParameter("@SysNo", SqlDbType.Int, 4); param.Value = model.SysNo; cmd.Parameters.Add(param); } if (model.Item != AppConst.IntNull) { strSql.Append("Item=@Item,"); SqlParameter param = new SqlParameter("@Item", SqlDbType.Int, 4); param.Value = model.Item; cmd.Parameters.Add(param); } if (model.Type != AppConst.IntNull) { strSql.Append("Type=@Type,"); SqlParameter param = new SqlParameter("@Type", SqlDbType.Int, 4); param.Value = model.Type; cmd.Parameters.Add(param); } if (model.Condition != AppConst.IntNull) { strSql.Append("Condition=@Condition,"); SqlParameter param = new SqlParameter("@Condition", SqlDbType.Int, 4); param.Value = model.Condition; cmd.Parameters.Add(param); } if (model.LogicSysNo != AppConst.IntNull) { strSql.Append("LogicSysNo=@LogicSysNo,"); SqlParameter param = new SqlParameter("@LogicSysNo", SqlDbType.Int, 4); param.Value = model.LogicSysNo; cmd.Parameters.Add(param); } if (model.Target != AppConst.IntNull) { strSql.Append("Target=@Target,"); SqlParameter param = new SqlParameter("@Target", SqlDbType.Int, 4); param.Value = model.Target; cmd.Parameters.Add(param); } if (model.Negative != AppConst.IntNull) { strSql.Append("Negative=@Negative,"); SqlParameter param = new SqlParameter("@Negative", SqlDbType.Int, 4); param.Value = model.Negative; cmd.Parameters.Add(param); } strSql.Remove(strSql.Length - 1, 1); strSql.Append(" where SysNo=@SysNo "); cmd.CommandText = strSql.ToString(); return(SqlHelper.ExecuteNonQuery(cmd, null)); }
protected void Unnamed1_Click(object sender, EventArgs e) { ltrResult.Text = ""; if (txtDate.Text == "" || txtDate1.Text == "") { ltrNotice.Text = "请选择日期"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';closeforseconds();", true); this.ClientScript.RegisterStartupScript(this.GetType(), "", "show(0);", true); return; } DateEntity m_date = new DateEntity(new DateTime(int.Parse(txtDate.Text.Split(new char[] { '-' })[0]), int.Parse(txtDate.Text.Split(new char[] { '-' })[1]), int.Parse(txtDate.Text.Split(new char[] { '-' })[2]), 0, 0, 0)); DateEntity m_date1 = new DateEntity(new DateTime(int.Parse(txtDate1.Text.Split(new char[] { '-' })[0]), int.Parse(txtDate1.Text.Split(new char[] { '-' })[1]), int.Parse(txtDate1.Text.Split(new char[] { '-' })[2]), 0, 0, 0)); if (m_date.Date >= m_date1.Date) { ltrNotice.Text = "开始日期必须在结束日期前"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';closeforseconds();", true); //this.ClientScript.RegisterStartupScript(this.GetType(), "", "show(0);", true); return; } List <RSH_BaziConditionMod> m_condition = new List <RSH_BaziConditionMod>(); for (int i = 0; i < 50; i++) { if (Repeater1.Items[i].FindControl("drpItem").Visible) { RSH_BaziConditionMod m_tmp = new RSH_BaziConditionMod(); m_tmp.Item = int.Parse(((DropDownList)Repeater1.Items[i].FindControl("drpItem")).SelectedValue); m_tmp.Type = int.Parse(((DropDownList)Repeater1.Items[i].FindControl("drpType")).SelectedValue); m_tmp.Condition = int.Parse(((DropDownList)Repeater1.Items[i].FindControl("drpCondition")).SelectedValue); m_tmp.Target = int.Parse(((DropDownList)Repeater1.Items[i].FindControl("drpTarget")).SelectedValue); m_condition.Add(m_tmp); } } for (int i = 0; m_date.Date < m_date1.Date; i++) { m_date = new DateEntity(m_date.Date.AddHours(2)); BaZiMod tmpzw = new BaZiMod(); tmpzw.BirthTime = m_date; tmpzw.Gender = AppEnum.Gender.male; BaZiBiz.GetInstance().TimeToBaZi(ref tmpzw); bool flag = true; for (int j = 0; j < 50; j++) { //逻辑筛选 } if (flag) { ltrResult.Text += m_date.Date.ToString("yyyy-MM-dd HH:00:00 ") + "<br />"; } } //this.ClientScript.RegisterStartupScript(this.GetType(), "", "show(0);", true); }
/// <summary> /// 得到一个对象实体 /// </summary> public RSH_BaziConditionMod GetModel(int SysNo) { StringBuilder strSql = new StringBuilder(); strSql.Append("select SysNo, Item, Type, Condition, LogicSysNo, Target, Negative from dbo.RSH_BaziCondition"); strSql.Append(" where SysNo=@SysNo "); SqlParameter[] parameters = { new SqlParameter("@SysNo", SqlDbType.Int, 4) }; parameters[0].Value = SysNo; RSH_BaziConditionMod model = new RSH_BaziConditionMod(); DataSet ds = SqlHelper.ExecuteDataSet(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["SysNo"].ToString() != "") { model.SysNo = int.Parse(ds.Tables[0].Rows[0]["SysNo"].ToString()); } if (ds.Tables[0].Rows[0]["Item"].ToString() != "") { model.Item = int.Parse(ds.Tables[0].Rows[0]["Item"].ToString()); } if (ds.Tables[0].Rows[0]["Type"].ToString() != "") { model.Type = int.Parse(ds.Tables[0].Rows[0]["Type"].ToString()); } if (ds.Tables[0].Rows[0]["Condition"].ToString() != "") { model.Condition = int.Parse(ds.Tables[0].Rows[0]["Condition"].ToString()); } if (ds.Tables[0].Rows[0]["LogicSysNo"].ToString() != "") { model.LogicSysNo = int.Parse(ds.Tables[0].Rows[0]["LogicSysNo"].ToString()); } if (ds.Tables[0].Rows[0]["Target"].ToString() != "") { model.Target = int.Parse(ds.Tables[0].Rows[0]["Target"].ToString()); } if (ds.Tables[0].Rows[0]["Negative"].ToString() != "") { model.Negative = int.Parse(ds.Tables[0].Rows[0]["Negative"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(RSH_BaziConditionMod model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into RSH_BaziCondition("); strSql.Append("Item,Type,Condition,LogicSysNo,Target,Negative)"); strSql.Append(" values ("); strSql.Append("@Item,@Type,@Condition,@LogicSysNo,@Target,@Negative)"); strSql.Append(";select @@IDENTITY"); SqlCommand cmd = new SqlCommand(strSql.ToString()); SqlParameter[] parameters = { new SqlParameter("@Item",SqlDbType.Int,4), new SqlParameter("@Type",SqlDbType.Int,4), new SqlParameter("@Condition",SqlDbType.Int,4), new SqlParameter("@LogicSysNo",SqlDbType.Int,4), new SqlParameter("@Target",SqlDbType.Int,4), new SqlParameter("@Negative",SqlDbType.Int,4), }; if (model.Item != AppConst.IntNull) parameters[0].Value = model.Item; else parameters[0].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[0]); if (model.Type != AppConst.IntNull) parameters[1].Value = model.Type; else parameters[1].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[1]); if (model.Condition != AppConst.IntNull) parameters[2].Value = model.Condition; else parameters[2].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[2]); if (model.LogicSysNo != AppConst.IntNull) parameters[3].Value = model.LogicSysNo; else parameters[3].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[3]); if (model.Target != AppConst.IntNull) parameters[4].Value = model.Target; else parameters[4].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[4]); if (model.Negative != AppConst.IntNull) parameters[5].Value = model.Negative; else parameters[5].Value = System.DBNull.Value; cmd.Parameters.Add(parameters[5]); return Convert.ToInt32(SqlHelper.ExecuteScalar(cmd, parameters)); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(RSH_BaziConditionMod model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(RSH_BaziConditionMod model) { return(dal.Add(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(RSH_BaziConditionMod model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into RSH_BaziCondition("); strSql.Append("Item,Type,Condition,LogicSysNo,Target,Negative)"); strSql.Append(" values ("); strSql.Append("@Item,@Type,@Condition,@LogicSysNo,@Target,@Negative)"); strSql.Append(";select @@IDENTITY"); SqlCommand cmd = new SqlCommand(strSql.ToString()); SqlParameter[] parameters = { new SqlParameter("@Item", SqlDbType.Int, 4), new SqlParameter("@Type", SqlDbType.Int, 4), new SqlParameter("@Condition", SqlDbType.Int, 4), new SqlParameter("@LogicSysNo", SqlDbType.Int, 4), new SqlParameter("@Target", SqlDbType.Int, 4), new SqlParameter("@Negative", SqlDbType.Int, 4), }; if (model.Item != AppConst.IntNull) { parameters[0].Value = model.Item; } else { parameters[0].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[0]); if (model.Type != AppConst.IntNull) { parameters[1].Value = model.Type; } else { parameters[1].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[1]); if (model.Condition != AppConst.IntNull) { parameters[2].Value = model.Condition; } else { parameters[2].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[2]); if (model.LogicSysNo != AppConst.IntNull) { parameters[3].Value = model.LogicSysNo; } else { parameters[3].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[3]); if (model.Target != AppConst.IntNull) { parameters[4].Value = model.Target; } else { parameters[4].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[4]); if (model.Negative != AppConst.IntNull) { parameters[5].Value = model.Negative; } else { parameters[5].Value = System.DBNull.Value; } cmd.Parameters.Add(parameters[5]); return(Convert.ToInt32(SqlHelper.ExecuteScalar(cmd, parameters))); }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { #region 输入检查 int count = 0; foreach (RepeaterItem item in Repeater1.Items) { if (item.ItemIndex > int.Parse(HiddenField1.Value)) { continue; } if (((TextBox)item.FindControl("txtSign1")).Text.Trim().Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "") != "") { ltrError.Text = "输入框只可输入括号"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); return; } if (((TextBox)item.FindControl("txtSign2")).Text.Trim().Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "") != "") { ltrError.Text = "输入框只可输入括号"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); return; } if (HiddenField2.Value.Contains("|" + item.ItemIndex + "|") && ((DropDownList)item.FindControl("drpLogic")).SelectedValue == "-1") { ltrError.Text = "有逻辑选择框未选择"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); return; } if (!HiddenField2.Value.Contains("|" + item.ItemIndex + "|") && ((DropDownList)item.FindControl("drpItem")).SelectedValue == "-1") { ltrError.Text = "有主语选择框未选择"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); return; } string tmpstr = ((TextBox)item.FindControl("txtSign1")).Text.Trim() + ((TextBox)item.FindControl("txtSign2")).Text.Trim(); foreach (char c in tmpstr) { if (c == '(' || c == '(') { count++; } if (c == ')' || c == ')') { count--; } } } if (count != 0) { ltrError.Text = "括号开闭数量不对称"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); return; } if (drpType.SelectedValue == "-1") { ltrError.Text = "请选择类型"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); return; } if (txtTitle.Text.Trim() == "") { ltrError.Text = "请输入标题"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); return; } if (txtDesc.Text.Trim() == "") { ltrError.Text = "请输入注释"; this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true); return; } #endregion RSH_BaziLogicMod m_logic = new RSH_BaziLogicMod(); if (sysno == AppConst.IntNull) { m_logic.Description = txtDesc.Text.Trim(); m_logic.DR = (int)AppEnum.State.normal; m_logic.Name = txtTitle.Text.Trim(); m_logic.Type = int.Parse(drpType.SelectedValue); m_logic.Logic = ""; m_logic.SysNo = RSH_BaziLogicBll.GetInstance().Add(m_logic); } else { m_logic = RSH_BaziLogicBll.GetInstance().GetModel(sysno); m_logic.Description = txtDesc.Text.Trim(); m_logic.DR = (int)AppEnum.State.normal; m_logic.Name = txtTitle.Text.Trim(); m_logic.Type = int.Parse(drpType.SelectedValue); m_logic.Logic = ""; RSH_BaziConditionBll.GetInstance().DeleteConditionsByLogic(sysno); } //List<RSH_BaziConditionMod> m_condtions = new List<RSH_BaziConditionMod>(); foreach (RepeaterItem item in Repeater1.Items) { if (item.ItemIndex > int.Parse(HiddenField1.Value)) { continue; } m_logic.Logic += ((TextBox)item.FindControl("txtSign1")).Text + "_"; if (HiddenField2.Value.Contains("|" + item.ItemIndex + "|")) { m_logic.Logic += "#" + ((DropDownList)item.FindControl("drpLogic")).SelectedValue + "_"; } else if (((DropDownList)item.FindControl("drpItem")).Style["display"] != "none") { RSH_BaziConditionMod tmp_c = new RSH_BaziConditionMod(); tmp_c.Item = int.Parse(((DropDownList)item.FindControl("drpItem")).SelectedValue); tmp_c.LogicSysNo = m_logic.SysNo; tmp_c.Type = int.Parse(((DropDownList)item.FindControl("drpType")).SelectedValue); tmp_c.Condition = int.Parse(((DropDownList)item.FindControl("drpCondition")).SelectedValue); tmp_c.Target = int.Parse(((DropDownList)item.FindControl("drpTarget")).SelectedValue); tmp_c.Negative = int.Parse(((DropDownList)item.FindControl("drpNegative")).SelectedValue); tmp_c.SysNo = RSH_BaziConditionBll.GetInstance().Add(tmp_c); m_logic.Logic += "@" + tmp_c.SysNo + "_"; } m_logic.Logic += ((TextBox)item.FindControl("txtSign2")).Text + "_"; m_logic.Logic += ((DropDownList)item.FindControl("drpSign")).SelectedValue + "_"; } m_logic.Logic = m_logic.Logic.Substring(0, m_logic.Logic.Length - 1); RSH_BaziLogicBll.GetInstance().Update(m_logic); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(RSH_BaziConditionMod model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update RSH_BaziCondition set "); SqlCommand cmd = new SqlCommand(); if (model.SysNo != AppConst.IntNull) { SqlParameter param = new SqlParameter("@SysNo", SqlDbType.Int, 4); param.Value = model.SysNo; cmd.Parameters.Add(param); } if (model.Item != AppConst.IntNull) { strSql.Append("Item=@Item,"); SqlParameter param = new SqlParameter("@Item", SqlDbType.Int, 4); param.Value = model.Item; cmd.Parameters.Add(param); } if (model.Type != AppConst.IntNull) { strSql.Append("Type=@Type,"); SqlParameter param = new SqlParameter("@Type", SqlDbType.Int, 4); param.Value = model.Type; cmd.Parameters.Add(param); } if (model.Condition != AppConst.IntNull) { strSql.Append("Condition=@Condition,"); SqlParameter param = new SqlParameter("@Condition", SqlDbType.Int, 4); param.Value = model.Condition; cmd.Parameters.Add(param); } if (model.LogicSysNo != AppConst.IntNull) { strSql.Append("LogicSysNo=@LogicSysNo,"); SqlParameter param = new SqlParameter("@LogicSysNo", SqlDbType.Int, 4); param.Value = model.LogicSysNo; cmd.Parameters.Add(param); } if (model.Target != AppConst.IntNull) { strSql.Append("Target=@Target,"); SqlParameter param = new SqlParameter("@Target", SqlDbType.Int, 4); param.Value = model.Target; cmd.Parameters.Add(param); } if (model.Negative != AppConst.IntNull) { strSql.Append("Negative=@Negative,"); SqlParameter param = new SqlParameter("@Negative", SqlDbType.Int, 4); param.Value = model.Negative; cmd.Parameters.Add(param); } strSql.Remove(strSql.Length - 1, 1); strSql.Append(" where SysNo=@SysNo "); cmd.CommandText = strSql.ToString(); return SqlHelper.ExecuteNonQuery(cmd, null); }
/// <summary> /// 得到一个对象实体 /// </summary> public RSH_BaziConditionMod GetModel(int SysNo) { StringBuilder strSql = new StringBuilder(); strSql.Append("select SysNo, Item, Type, Condition, LogicSysNo, Target, Negative from dbo.RSH_BaziCondition"); strSql.Append(" where SysNo=@SysNo "); SqlParameter[] parameters = { new SqlParameter("@SysNo", SqlDbType.Int,4 ) }; parameters[0].Value = SysNo; RSH_BaziConditionMod model = new RSH_BaziConditionMod(); DataSet ds = SqlHelper.ExecuteDataSet(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["SysNo"].ToString() != "") { model.SysNo = int.Parse(ds.Tables[0].Rows[0]["SysNo"].ToString()); } if (ds.Tables[0].Rows[0]["Item"].ToString() != "") { model.Item = int.Parse(ds.Tables[0].Rows[0]["Item"].ToString()); } if (ds.Tables[0].Rows[0]["Type"].ToString() != "") { model.Type = int.Parse(ds.Tables[0].Rows[0]["Type"].ToString()); } if (ds.Tables[0].Rows[0]["Condition"].ToString() != "") { model.Condition = int.Parse(ds.Tables[0].Rows[0]["Condition"].ToString()); } if (ds.Tables[0].Rows[0]["LogicSysNo"].ToString() != "") { model.LogicSysNo = int.Parse(ds.Tables[0].Rows[0]["LogicSysNo"].ToString()); } if (ds.Tables[0].Rows[0]["Target"].ToString() != "") { model.Target = int.Parse(ds.Tables[0].Rows[0]["Target"].ToString()); } if (ds.Tables[0].Rows[0]["Negative"].ToString() != "") { model.Negative = int.Parse(ds.Tables[0].Rows[0]["Negative"].ToString()); } return model; } else { return null; } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(RSH_BaziConditionMod model) { return dal.Add(model); }