示例#1
0
    /// <summary>
    /// 计量单位验证
    /// </summary>
    /// <param name="value"></param>
    /// <param name="str"></param>
    /// <param name="index"></param>
    /// <param name="Tran"></param>
    /// <returns></returns>
    public string CheckGoodsUnit(string value, string str, SqlTransaction Tran)
    {
        List <Hi.Model.BD_DefDoc_B> l = new Hi.BLL.BD_DefDoc_B().GetList("", " AtVal = '" + value.Trim() + "' and AtName='计量单位' and compid=" + this.CompID + " and isnull(dr,0)=0", "", Tran);

        if (l.Count == 0)
        {
            List <Hi.Model.BD_DefDoc> list = new Hi.BLL.BD_DefDoc().GetList("", " AtName='计量单位' and compid=" + this.CompID + " and isnull(dr,0)=0", "", Tran);
            int defid = 0;
            if (list.Count == 0)
            {
                Hi.Model.BD_DefDoc doc = new Hi.Model.BD_DefDoc();
                doc.CompID     = this.CompID;
                doc.AtCode     = "";
                doc.AtName     = "计量单位";
                doc.ts         = DateTime.Now;
                doc.modifyuser = this.UserID;
                doc.dr         = 0;
                defid          = new Hi.BLL.BD_DefDoc().Add(doc, Tran);
            }
            else
            {
                defid = list[0].ID;
            }
            Hi.Model.BD_DefDoc_B item = new Hi.Model.BD_DefDoc_B();
            item.AtVal      = value;
            item.AtName     = "计量单位";
            item.CompID     = this.CompID;
            item.DefID      = defid;
            item.ts         = DateTime.Now;
            item.dr         = 0;
            item.modifyuser = this.UserID;
            int count = new Hi.BLL.BD_DefDoc_B().Add(item, Tran);
            //if (count == 0)
            //{
            //    JScript.AlertMethod(this, "Excel没有数据,请重新导入", JScript.IconOption.错误, "function(){location.href='ImportGoods.aspx'}");
            //    throw new ApplicationException("Excel行号为:&nbsp;<i error>" + (index + TitleIndex + 1) + "</i> &nbsp;&nbsp;的数据有误。" + str + "录入数据库失败,请修改后重新导入。");
            //}
        }
        return(value);
    }
示例#2
0
    /// <summary>
    /// 添加费用科目
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected string AddFykm(string unit)
    {
        SqlTransaction Tran = null;

        try
        {
            Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
            //新增数据字典
            Hi.Model.BD_DefDoc doc = new Hi.Model.BD_DefDoc();
            doc.CompID     = this.CompID;
            doc.AtCode     = "";
            doc.AtName     = "费用科目";
            doc.ts         = DateTime.Now;
            doc.modifyuser = UserID;
            doc.dr         = 0;
            List <Hi.Model.BD_DefDoc> ll = new Hi.BLL.BD_DefDoc().GetList("", "isnull(dr,0)=0 and compid=" + this.CompID + " and atname='费用科目'", "");
            int defid = 0;
            if (ll.Count == 0)
            {
                defid = new Hi.BLL.BD_DefDoc().Add(doc, Tran);
            }
            else
            {
                defid = ll[0].ID;
            }
            if (defid != 0)
            {
                Hi.Model.BD_DefDoc_B doc2 = new Hi.Model.BD_DefDoc_B();
                doc2.CompID     = this.CompID;
                doc2.DefID      = defid;
                doc2.AtName     = "费用科目";
                doc2.AtVal      = unit; //txtunits.Value.Trim();
                doc2.ts         = DateTime.Now;
                doc2.dr         = 0;
                doc2.modifyuser = this.UserID;
                List <Hi.Model.BD_DefDoc_B> lll = new Hi.BLL.BD_DefDoc_B().GetList("", "isnull(dr,0)=0 and compid=" + this.CompID + " and atname='费用科目' and defid=" + defid + " and atval='" + unit + "'", "");
                if (lll.Count == 0)
                {
                    new Hi.BLL.BD_DefDoc_B().Add(doc2, Tran);
                }
                else
                {
                    return("[{\"AtVal\":\"ycz\"}]");
                }
            }
            Tran.Commit();
            List <Hi.Model.BD_DefDoc> l = new Hi.BLL.BD_DefDoc().GetList("", "AtName='费用科目' and compid=" + this.CompID + " and isnull(dr,0)=0", "");
            if (l.Count > 0)
            {
                List <Hi.Model.BD_DefDoc_B> llll = new Hi.BLL.BD_DefDoc_B().GetList("", "DefID=" + l[0].ID + "and ISNULL(dr,0)=0 and compid=" + this.CompID, "id desc");
                if (llll.Count > 0)
                {
                    DataTable dt = Common.FillDataTable(llll);
                    if (dt.Rows.Count != 0)
                    {
                        return(ConvertJson.ToJson(dt));
                    }
                }
            }
            return("[{\"AtVal\":\"cc\"}]");
            // this.txtunit.Value = unit;
        }
        catch (Exception)
        {
            if (Tran != null)
            {
                if (Tran.Connection != null)
                {
                    Tran.Rollback();
                }
            }
            return("[{\"AtVal\":\"sb\"}]");
        }
        finally
        {
            DBUtility.SqlHelper.ConnectionClose();
        }
    }