Exemple #1
0
        private void setReleaseId()
        {
            try
            {
                string curr_date = DateTime.Today.ToString("yyyy/MM/dd").Replace("/", "");
                int    prefix    = MANAGEDB.getIdPrefix("stockReleaseId");
                string newId     = string.Concat(curr_date, prefix.ToString(), "0001");

                //get max item Id
                long maxId = MANAGEDB.getMaxId("releaseId", "tbl_stockrelease");

                //if there are no any id in db
                if (maxId <= 1)
                {
                    //set the start Id
                    txt_releaseId.Text = newId;
                }
                else
                {
                    string tmp = maxId.ToString().Substring(0, 8);

                    //same day stock entry
                    if (string.Equals(curr_date, tmp))
                    {
                        txt_releaseId.Text = maxId.ToString();
                    }
                    //different day stock entry
                    else
                    {
                        txt_releaseId.Text = newId;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }