Example #1
0
        public static int InsertOrUpdateT_OE_ColumnConfig(global::System.Int32? cOLUMNCONFIG_IDX, global::System.String cOLUMN_NAME,
           global::System.String uNIT, global::System.Double mAXVALUE, global::System.Double mINVALUE,
           global::System.Boolean cOLUMNDONTSEND)
        {
            using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities())
            {
                Boolean insInd = false;
                try
                {
                    T_OE_COLUMNCONFIG a = new T_OE_COLUMNCONFIG();

                    if (cOLUMNCONFIG_IDX != null)
                        a = (from c in ctx.T_OE_COLUMNCONFIG
                             where c.COLUMNCONFIG_IDX == cOLUMNCONFIG_IDX
                             select c).FirstOrDefault();

                    if (cOLUMNCONFIG_IDX == null) //insert case
                    {
                        a = new T_OE_COLUMNCONFIG();
                        insInd = true;
                    }

                    if (cOLUMN_NAME != null) a.COLUMN_NAME = cOLUMN_NAME;
                    if (uNIT != null) a.UNIT = uNIT;
                    a.MAX_VALUE = mAXVALUE;
                    a.MIN_VALUE = mINVALUE;
                    a.COLUMN_DONT_SEND = cOLUMNDONTSEND;

                    if (insInd) //insert case
                    {
                        //    a.CREATE_USERID = cREATE_USER.ToUpper();
                        //    a.CREATE_DT = System.DateTime.Now;
                        ctx.AddToT_OE_COLUMNCONFIG(a);
                    }
                    else
                    {
                        //    a.UPDATE_USERID = cREATE_USER.ToUpper();
                        //    a.UPDATE_DT = System.DateTime.Now;
                    }

                    ctx.SaveChanges();

                    return a.COLUMNCONFIG_IDX;
                }
                catch (Exception ex)
                {
                    return 0;
                }
            }
        }