Ejemplo n.º 1
0
        public static int UpdateT_WQX_REF_DATAByIDX(global::System.Int32 IDX, global::System.String vALUE, global::System.String tEXT, Boolean ActInd)
        {
            try
            {
                TWqxRefData a = new TWqxRefData();
                a = (from c in _db.TWqxRefData
                     where c.RefDataIdx == IDX
                     select c).FirstOrDefault();

                if (vALUE != null)
                {
                    a.Value = vALUE;
                }
                if (tEXT != null)
                {
                    a.Text = Utils.SubStringPlus(tEXT, 0, 200);
                }
                a.UpdateDt = System.DateTime.Now;
                a.ActInd   = ActInd;
                _db.TWqxRefData.Update(a);
                _db.SaveChanges();
                return(1);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Ejemplo n.º 2
0
        //******************REF DATA****************************************
        public static int InsertOrUpdateT_WQX_REF_DATA(global::System.String tABLE, global::System.String vALUE, global::System.String tEXT, global::System.Boolean?UsedInd)
        {
            try
            {
                Boolean insInd = true;

                TWqxRefData a = new TWqxRefData();

                if (_db.TWqxRefData.Any(o => o.Value == vALUE && o.Table == tABLE))
                {
                    //update case
                    a = (from c in _db.TWqxRefData
                         where c.Value == vALUE &&
                         c.Table == tABLE
                         select c).FirstOrDefault();
                    insInd = false;
                }

                a.Table = tABLE;
                a.Value = vALUE;
                a.Text  = Utils.SubStringPlus(tEXT, 0, 200);
                if (UsedInd != null)
                {
                    a.UsedInd = UsedInd;
                }

                a.UpdateDt = System.DateTime.Now;
                a.ActInd   = true;

                if (insInd) //insert case
                {
                    if (UsedInd == null)
                    {
                        a.UsedInd = true;
                    }
                    _db.TWqxRefData.Add(a);
                }
                else
                {
                    _db.TWqxRefData.Update(a);
                }
                _db.SaveChanges();
                return(1);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }