Example #1
0
        public static string LayMaTuTangCongTy()
        {
            DataTable t = new DataTable();

            t = new DataTable();
            t = FunctionHelper.LoadDM("select * from config where config_name='MACTY' and Year = " + DateTime.Now.Year);
            if (t.Rows.Count > 0)
            {
                string     str = string.Format("update CONFIG set Config_value = Config_value + 1 where config_name='MACTY'");
                SqlCommand cmd = new SqlCommand(str, clsConnection._conn);
                cmd.ExecuteNonQuery();
                return(t.Rows[0]["Config_first"].ToString() + t.Rows[0]["Config_value"].ToString() + string.Empty);
            }
            else
            {
                string     _number = DateTime.Now.Year + "001";
                string     str     = string.Format("update CONFIG set Config_value ={0}, Year={1}  where config_name='MACTY'", Convert.ToInt32(_number) + 1, DateTime.Now.Year);
                SqlCommand cmd     = new SqlCommand(str, clsConnection._conn);
                cmd.ExecuteNonQuery();
                return("CTY" + _number);
            }
        }