コード例 #1
0
        public List<Generate_ID> getGenerateID(Generate_ID gid)
        {
            var q = from gd in ContextDB.Generate_ID
                    where (gd.ID == gid.ID || gid.ID == null)
                    && (gd.Table_Name == gid.Table_Name || gid.Table_Name == null)
                    select gd;

            return q.ToList<Generate_ID>();
        }
コード例 #2
0
        public bool updateGenerateID(Generate_ID gid)
        {
            try
            {
                Generate_ID gn = (Generate_ID)getGenerateID(gid).First();
                gn.ID = gid.ID == null ? gn.ID : gid.ID;
                gn.Last_ID = gid.Last_ID == null ? gn.Last_ID : gid.Last_ID;
                gn.Seg1 = gid.Seg1 == null ? gn.Seg1 : gid.Seg1;
                gn.Seg2 = gid.Seg2 == null ? gn.Seg2 : gid.Seg2;

                ContextDB.SaveChanges();

                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
コード例 #3
0
        public string Generate_ID(string tablename)
        {
            string ret = null;
            string val1 = null;
            string val2 = null;
            Generate_ID gen = new Generate_ID();
            Generate_IDEnt genE = new Generate_IDEnt();

            switch (tablename)
            {
                case "Requisition":
                    {
                        gen = (from g in ContextDB.Generate_ID
                               where g.Table_Name == tablename
                               select g).First();

                        if (gen.Seg1 < 99)
                        {
                            val1 = (gen.Seg1 + 1).ToString();
                        }
                        else
                        {
                            val2 = (gen.Last_ID + 1).ToString();
                            gen.Last_ID = 10;
                        }

                        //val1 = (gen.Last_ID + 1).ToString();
                        //val2 = (gen.Seg1 + 1).ToString();
                        ret = val2 + "/" + val1;

                        //gen.Last_ID = gen.Last_ID + 1;
                        //gen.Seg2 = gen.Seg2 + 1;

                        //genE.updateGenerateID(gen);

                        break;
                    }

                case "Purchase_Order":
                    {
                        gen = (from g in ContextDB.Generate_ID
                                where g.Table_Name == tablename
                                select g).First();
                        ret = (gen.Last_ID + 1).ToString();

                        //gen.Last_ID = gen.Last_ID + 1;

                        //genE.updateGenerateID(gen);

                        break;
                    }

                case "StockCard_Detail":
                    {
                        gen = (from g in ContextDB.Generate_ID
                               where g.Table_Name == tablename
                               select g).First();
                        ret = "TND" + (gen.Last_ID + 1).ToString();

                        break;
                    }
                 case "Disbursement":
                    {
                        gen = (from g in ContextDB.Generate_ID
                               where g.Table_Name == tablename
                               select g).First();
                        ret = (gen.Last_ID + 1).ToString();

                        break;
                    }

                 case "Adjustment_Voucher":
                    {
                        gen = (from g in ContextDB.Generate_ID
                               where g.Table_Name == tablename
                               select g).First();

                        if (gen.Last_ID < 99)
                        {
                            val1 = (gen.Last_ID + 1).ToString();
                        }
                        else
                        {
                            val2 = (gen.Seg1 + 1).ToString();
                            gen.Last_ID = 10;
                        }

                        break;

                    }

                default :
                    return "xxx";
            }
            return ret;
        }
コード例 #4
0
        public bool Increament_GenID(int id)
        {
            try
            {
                Generate_IDEnt gEnt = new Generate_IDEnt();
                Generate_ID gid = new Generate_ID();
                gid.ID = id;
                gid.Last_ID = (from g in ContextDB.Generate_ID
                               where g.ID == id
                               select g.Last_ID).SingleOrDefault() + 1;
                gEnt.updateGenerateID(gid);

                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
コード例 #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Generate_ID EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToGenerate_ID(Generate_ID generate_ID)
 {
     base.AddObject("Generate_ID", generate_ID);
 }
コード例 #6
0
 /// <summary>
 /// Create a new Generate_ID object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static Generate_ID CreateGenerate_ID(global::System.Int32 id)
 {
     Generate_ID generate_ID = new Generate_ID();
     generate_ID.ID = id;
     return generate_ID;
 }