/// <summary> /// 查询是否存在指定的价表项目记录 /// </summary> /// <param name="iChargeItemDict"></param> /// <returns></returns> public override bool Exists(IModel iChargeItemDict) { MChargeItemDict chargeItemDict = (MChargeItemDict)iChargeItemDict; strSql = "select * from " + TableName + " where CHARGE_ITEM_CLASS = '" + chargeItemDict.CHARGE_ITEM_CLASS + "' and CHARGE_ITEM_CODE='" + chargeItemDict.CHARGE_ITEM_CODE + "' and CHARGE_ITEM_SPEC='" + chargeItemDict.CHARGE_ITEM_SPEC + "' and UNITS='" + chargeItemDict.UNITS + "' and START_DATE='" + chargeItemDict.START_DATE + "'"; return(recordIsExist(strSql)); }
private void btn_Modify_Click(object sender, EventArgs e) { if (RowTxt == "") { return; } MChargeItemDict mcid = ChgNull(1); if (mcid == null) { return; } int i = BChrgItDit.Update(mcid, " where CHARGE_ITEM_CODE='" + mcid.CHARGE_ITEM_CODE + "'"); if (i >= 0) { MessageBoxEx.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); FindData("");; } else { MessageBoxEx.Show("修改失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 重新获取指定价表项目记录 /// </summary> /// <param name="iChargeItemDict"></param> /// <returns></returns> public override IModel GetModel(IModel iChargeItemDict) { MChargeItemDict chargeItemDict = (MChargeItemDict)iChargeItemDict; strSql = "select * from " + TableName + " where CHARGE_ITEM_CLASS = '" + chargeItemDict.CHARGE_ITEM_CLASS + "' and CHARGE_ITEM_CODE='" + chargeItemDict.CHARGE_ITEM_CODE + "' and CHARGE_ITEM_SPEC='" + chargeItemDict.CHARGE_ITEM_SPEC + "' and UNITS='" + chargeItemDict.UNITS + "' and START_DATE='" + chargeItemDict.START_DATE + "'"; DataTable dt = GetDataTable(strSql); if (dt.Rows.Count == 0) { return(null); } MChargeItemDict model = new MChargeItemDict(); model.CHARGE_ITEM_CLASS = dt.Rows[0]["CHARGE_ITEM_CLASS"].ToString(); model.CHARGE_ITEM_CODE = dt.Rows[0]["CHARGE_ITEM_CODE"].ToString(); model.CHARGE_ITEM_SPEC = dt.Rows[0]["CHARGE_ITEM_SPEC"].ToString(); model.UNITS = dt.Rows[0]["UNITS"].ToString(); if (dt.Rows[0]["ENTER_DATE"].ToString() == "") { model.ENTER_DATE = null; } else { model.ENTER_DATE = Convert.ToDateTime(dt.Rows[0]["ENTER_DATE"].ToString()); } model.CHARGE_ITEM_NAME = dt.Rows[0]["CHARGE_ITEM_NAME"].ToString(); model.INPUT_CODE = dt.Rows[0]["INPUT_CODE"].ToString(); if (dt.Rows[0]["PRICE"].ToString() == "") { model.PRICE = null; } else { model.PRICE = Convert.ToDecimal(dt.Rows[0]["PRICE"].ToString()); } if (dt.Rows[0]["STOP_DATE"].ToString() == "") { model.STOP_DATE = null; } else { model.STOP_DATE = Convert.ToDateTime(dt.Rows[0]["STOP_DATE"].ToString()); } model.OPERATOR = dt.Rows[0]["OPERATOR"].ToString(); if (dt.Rows[0]["ENTER_DATE"].ToString() == "") { model.ENTER_DATE = null; } else { model.ENTER_DATE = Convert.ToDateTime(dt.Rows[0]["ENTER_DATE"].ToString()); } model.MEMO = dt.Rows[0]["MEMO"].ToString(); return(model); }
/// <summary> /// 插入一条价格项目字典 /// </summary> /// <param name="iChargeItemDict"></param> /// <returns></returns> public override int Add(IModel iChargeItemDict) { MChargeItemDict chargeItemDict = (MChargeItemDict)iChargeItemDict; Hashtable ht = new Hashtable(); ht.Add("CHARGE_ITEM_CODE", chargeItemDict.CHARGE_ITEM_CODE); ht.Add("CHARGE_ITEM_SPEC", chargeItemDict.CHARGE_ITEM_SPEC); ht.Add("UNITS", chargeItemDict.UNITS); ht.Add("START_DATE", chargeItemDict.START_DATE); ht.Add("CHARGE_ITEM_NAME", chargeItemDict.CHARGE_ITEM_NAME); ht.Add("INPUT_CODE", chargeItemDict.INPUT_CODE); ht.Add("PRICE", chargeItemDict.PRICE); ht.Add("STOP_DATE", chargeItemDict.STOP_DATE); ht.Add("OPERATOR", chargeItemDict.OPERATOR); ht.Add("ENTER_DATE", chargeItemDict.ENTER_DATE); ht.Add("MEMO", chargeItemDict.MEMO); return(ExecuteSql(StringConstructor.InsertSql(TableName, ht).ToString())); }
private void btn_Add_Click(object sender, EventArgs e) { MChargeItemDict mcid = ChgNull(0); if (mcid == null) { return; } int i = BChrgItDit.Add(mcid); if (i > 0) { MessageBoxEx.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); FindData("");; } else { MessageBoxEx.Show("添加失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 判断输入的条件是否为正确的,Flag-0:新增;1:修改 /// </summary> /// <returns>返回null说明输入有误</returns> private MChargeItemDict ChgNull(int Flag) { MChargeItemDict mChrItmDit = new MChargeItemDict(); mChrItmDit.CHARGE_ITEM_CLASS = cmb_CHARGE_ITEM_CLASS.SelectedValue.ToString(); //if (cmb_CHARGE_ITEM_CLASS.Text.Trim() == "") //{ // MessageBoxEx.Show("项目分类不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // return null; //} //else //{ // DataRow[] dr = DT_CHhargeItemClass.Select("CLASS_NAME='" + cmb_CHARGE_ITEM_CLASS.Text + "'"); // if (dr.Length > 0) // mChrItmDit.CHARGE_ITEM_CLASS = dr[0]["CLASS_CODE"].ToString(); // else // { // MessageBoxEx.Show("项目分类设置错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // return null; // } //} if (txt_CHARGE_ITEM_CODE.Text.Trim() == "") { MessageBoxEx.Show("项目代码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } else { mChrItmDit.CHARGE_ITEM_CODE = txt_CHARGE_ITEM_CODE.Text.Trim(); bool bl = BChrgItDit.ExistsWhere("CHARGE_ITEM_CODE ='" + mChrItmDit.CHARGE_ITEM_CODE + "'"); if (bl) { if (Flag == 0) { MessageBoxEx.Show("项目代码已经存在,请重新设定!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } else { if (RowTxt != mChrItmDit.CHARGE_ITEM_CODE) { MessageBoxEx.Show("修改后的项目代码已经存在,请重新设定!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } } } else { if (Flag == 1) { MessageBoxEx.Show("未能找到此项目代码的记录," + "\r\n" + "请注意:项目代码为不可修改内容!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } } } if (txt_CHARGE_ITEM_SPEC.Text.Trim() == "") { MessageBoxEx.Show("项目规格不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } else { mChrItmDit.CHARGE_ITEM_SPEC = txt_CHARGE_ITEM_SPEC.Text.Trim(); } if (txt_CHARGE_ITEM_NAME.Text.Trim() == "") { MessageBoxEx.Show("项目名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } mChrItmDit.CHARGE_ITEM_NAME = txt_CHARGE_ITEM_NAME.Text.Trim(); //else //{ // mChrItmDit.CHARGE_ITEM_NAME = txt_CHARGE_ITEM_NAME.Text.Trim(); // bool bl1 = BChrgItDit.ExistsWhere("CHARGE_ITEM_NAME='" + mChrItmDit.CHARGE_ITEM_NAME + "'"); // if (bl1) // { // if (Flag == 0) // { // MessageBoxEx.Show("项目名称已经存在,请重新设定!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // return null; // } // else // { // if (RowItemName != mChrItmDit.CHARGE_ITEM_NAME) // { // MessageBoxEx.Show("修改后的项目名称已经存在,请重新设定!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // return null; // } // } // } //} if (txt_INPUT_CODE.Text.Trim() != "") { mChrItmDit.INPUT_CODE = txt_INPUT_CODE.Text.Trim(); } if (txt_PRICE.Text.Trim() != "") { try { mChrItmDit.PRICE = Convert.ToDecimal(txt_PRICE.Text.Trim()); } catch { MessageBoxEx.Show("价格输入错误,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } } else { MessageBoxEx.Show("价格不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } if (txt_UNITS.Text.Trim() == "") { MessageBoxEx.Show("单位不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } else { mChrItmDit.UNITS = txt_UNITS.Text.Trim(); } if (txt_OPERATOR.Text.Trim() != "") { mChrItmDit.OPERATOR = txt_OPERATOR.Text.Trim(); } mChrItmDit.ENTER_DATE = dtp_ENTER_DATE.Value; mChrItmDit.START_DATE = dtp_START_DATE.Value; if (txt_STOP_DATE.Text.Trim() != "") { try { mChrItmDit.STOP_DATE = Convert.ToDateTime(txt_STOP_DATE.Text.Trim()); } catch { MessageBoxEx.Show("停止日期输入格式错误,不是正确的日期!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } } if (txt_MEMO.Text.Trim() != "") { mChrItmDit.MEMO = txt_MEMO.Text.Trim(); } return(mChrItmDit); }