예제 #1
0
        /// <summary>
        /// 根据oid删除
        /// </summary>
        /// <returns></returns>
        private string deleteData()
        {
            string oids = getUTF8ToString("oids");

            if (string.IsNullOrEmpty(oids))
            {
                return("false");
            }

            string lb = getUTF8ToString("lb");

            if (lb == "readWords" || lb == "hisWords")
            {
                return("false");
            }

            try
            {
                string[] oidsArray = oids.Split(',');

                foreach (string oid in oidsArray)
                {
                    if (string.IsNullOrEmpty(oid))
                    {
                        continue;
                    }

                    DefVal dv = new DefVal();
                    dv.RetrieveByAttr(DefValAttr.OID, oid);

                    dv.Delete();
                }

                return("true");
            }
            catch (Exception)
            {
                return("false");
            }
        }
예제 #2
0
        /// <summary>
        /// 保存历史数据
        /// </summary>
        /// <returns></returns>
        private string saveHistoryData()
        {
            string lb = getUTF8ToString("lb");

            if (lb == "readWords" || lb == "hisWords")
            {
                return("false");
            }

            string enName  = getUTF8ToString("FK_MapData");
            string AttrKey = getUTF8ToString("AttrKey");
            string str     = getUTF8ToString("str");


            string sql = "select * from sys_defval where LB='2' and FK_Emp='" + WebUser.No
                         + "' and FK_MapData='" + enName + "' and AttrKey='" + AttrKey + "' and CurValue='" + str + "'";

            if (DBAccess.RunSQLReturnCOUNT(sql) != 0)//禁止添加重复数据
            {
                return("false");
            }

            sql = "select * from sys_defval where LB='2' and FK_Emp='" + WebUser.No
                  + "' and FK_MapData='" + enName + "' and AttrKey='" + AttrKey + "'";

            DataTable dt = DBAccess.RunSQLReturnTable(sql);

            DefVal dv = new DefVal();

            if (dt.Rows.Count == 50)//动态更新数据,限制50条
            {
                try
                {
                    int minOid = int.Parse(dt.Rows[0]["OID"].ToString());

                    foreach (DataRow dr in dt.Rows)
                    {
                        int drOid = int.Parse(dr["OID"].ToString());
                        if (minOid > drOid)
                        {
                            minOid = drOid;
                        }
                    }

                    dv = new DefVal();
                    dv.RetrieveByAttr(DefValAttr.OID, minOid);

                    dv.Delete();
                }
                catch (Exception)
                {
                    if (dt.Rows.Count != 0)
                    {
                        return("false");
                    }
                }
            }

            dv            = new DefVal();
            dv.FK_MapData = enName;
            dv.AttrKey    = AttrKey;
            dv.LB         = "2";
            dv.FK_Emp     = WebUser.No;
            dv.CurValue   = str;

            dv.Insert();

            return("true");
        }
예제 #3
0
        private void BPToolBar1_ButtonClick(object sender, System.EventArgs e)
        {
            try
            {
                string id = "";
                try
                {
                    ToolbarBtn btn = (ToolbarBtn)sender;
                    id = btn.ID;
                }
                catch
                {
                    if (this.CurrentSelectedCheckButton.Index == 2)
                    {
                        this.BPToolBar1.GetBtnByKey(NamesOfBtn.Delete).Enabled = false;
                    }
                    else
                    {
                        this.BPToolBar1.GetBtnByKey(NamesOfBtn.Delete).Enabled = true;
                    }
                    this.SetDGData();
                    return;
                }
                switch (id)
                {
                case NamesOfBtn.Update:
                    if (AttrKeyValue == null || AttrKeyValue == "")
                    {
                        throw new Exception("@默认值不能为空.");
                    }
                    //DBAccess.RunSQL("update  Sys_UIDefaultValue set DefaultVal='"+this.AttrKeyValue+"' WHERE EnsName='"+this.EnsName+"' AND AttrKey='"+this.AttrKey+"' AND DefaultVal='"+this.DG1.CurrendSelectedNo+"'" );
                    this.ResponseWriteBlueMsg_UpdataOK();
                    this.SetDGData();
                    break;

                case NamesOfBtn.Confirm:
                    this.Confirm();
                    break;

                case NamesOfBtn.Close:
                    this.WinClose();
                    break;

                case NamesOfBtn.Delete:
                    if (this.CurrentSelectedCheckButton.Index == 0)
                    {
                        foreach (ListItem li in this.CBL1.Items)
                        {
                            if (li.Selected == false)
                            {
                                continue;
                            }

                            BP.Sys.DefVal dv = new DefVal();
                            dv.Delete(DefValAttr.Val, li.Text,
                                      DefValAttr.EnsName, this.EnsName,
                                      DefValAttr.FK_Emp, this.FK_Emp);
                        }
                    }
                    else
                    {
                        foreach (ListItem li in this.CBL1.Items)
                        {
                            if (li.Selected == false)
                            {
                                continue;
                            }

                            BP.Sys.DefVal dv = new DefVal();
                            dv.Delete(DefValAttr.Val, li.Text,
                                      DefValAttr.EnsName, this.EnsName,
                                      DefValAttr.FK_Emp, "0");
                            // DBAccess.RunSQL("DELETE FROM Sys_UIDefaultValue WHERE DefaultVal='" + li.Text + "' AND ENSCLASSNAME='" + this.EnsName + "' AND AttrKey='" + this.AttrKey + "' AND No='0'");
                        }
                    }
                    this.ResponseWriteBlueMsg_DeleteOK();
                    this.SetDGData();
                    break;

                case NamesOfBtn.New:
                    //this.DG1.SelectedIndex =-1;
                    this.TB_Key.Text = "";
                    break;

                case NamesOfBtn.Help:
                    this.Helper();
                    break;

                default:
                    this.SetDGData();
                    break;
                }
            }
            catch (Exception ex)
            {
                this.Response.Write(ex.Message);
                //this.ResponseWriteRedMsg(ex);
            }
        }